Friday, December 16, 2016

Node.js Tutorial for Beginners 12 - Basics of Streams - Writable Streams



var fs = require('fs');

var readStream = fs.createReadStream('file.txt');
readStream.setEncoding('utf8');
var writeStream = fs.createWriteStream('write_file.txt');

readStream.on('data', function(chunk) {
    console.log('------------------------------------------------------------');
    writeStream.write(chunk);
})

readStream.on('end', function(chunk) {

    console.log('--------------------End----------------------------------------');
})