PhantomJS read 读取文件


发布日期 : 2023-10-19 06:11:19 UTC

访问量: 9 次浏览

PhantomJS read读取

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

语法

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();

测试 .txt 文件

I am Testing Phantomjs

上述程序生成以下输出

I am Testing Phantomjs