public
Last active

Empty file written - demo code

  • Download Gist
emptyfile.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14
var fs = require('fs');
 
var file_tree = ['test1.txt', 'test2.txt'];
var data = ['d1', 'd2'];
 
for(i in file_tree) {
 
fp = fs.createWriteStream(file_tree[i]);
 
for(i in data) {
fp.write(data[i]+'\n', function (err) { if(err) throw err;});
}
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.