Node.js fs createWriteStream()
write UTF8 data
var fs = require("fs"); var data = 'abc'; var writeStream = fs.createWriteStream('input.txt'); writeStream.write(data,'UTF8'); writeStream.end();/* w w w.j av a 2s .c o m*/ writeStream.on('finish',function(){ console.log("finished"); }); writeStream.on('error',function(err){ console.log(err.stack); });