PhantomJS - read 方法

此方法读取指定文件中的数据。

语法

其语法如下 −

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.html