PhantomJS touch 使用方法


发布日期 : 2024-08-16 20:02:11 UTC

访问量: 10 次浏览

PhantomJS touch

touch 方法创建一个空文件。

语法

其语法如下:

var fs = require('fs');
fs.touch(path);

示例

下面的示例展示了 touch 方法的工作原理。

命令
phantomjs
touch.js hello.txt

var fs = require('fs');
var system = require('system');
var path = system.args[1];
var md = fs.touch(path);

console.log("file is present : "+fs.isFile(path));
phantom.exit();

它将生成下面的输出

file is present : true