
- 文件系统模块
- PhantomJS - 属性
- PhantomJS - 方法
- 系统模块
- PhantomJS - 属性
- 网络服务器模块
- PhantomJS - 属性
- PhantomJS - 方法
- 杂项
- 命令行界面
- PhantomJS - 屏幕截图
- PhantomJS - 网页自动化
- PhantomJS - 网络监控
- PhantomJS - 测试
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 实用资源
- PhantomJS - 快速指南
- PhantomJS - 实用资源
- PhantomJS - 讨论
PhantomJS - 读取
此方法读取指定文件中存在的数据。
语法
其语法如下 −
var fs = require('fs'); fs.read(path);
示例
我们来看一个示例,了解 **read** 方法如何工作。
命令 − phantomjs read.js test.txt
var fs = require('fs'); var system = require('system'); var path = system.args[1]; console.log(fs.read(path)); phantom.exit();
Test.txt 文件
I am Testing Phantomjs
以上程序会生成以下 **输出**。
I am Testing Phantomjs
phantomjs_file_system_module_methods.htm
广告