PhantomJS - touch



This method creates an empty file.

Syntax

Its syntax is as follows −

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

Example

The following example shows how the touch method works.

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

It will generate the following output.

file is present : true
phantomjs_file_system_module_methods.htm
Advertisements