11 Program to demonstrate Writable Stream in NodeJS

Program:

var http = require('http');

var fs = require('fs');



var readStream = fs.createReadStream(__dirname+'/demo.txt');

var writeStream = fs.createWriteStream(__dirname+'/demowrite.txt');



var chuckCounter = 0;

readStream.on('data',function(d){

    //console.log("This is the read data:"+d);

    writeStream.write(d);

    chuckCounter++;

    console.log(chuckCounter);

});



Output:

Writable Stream in NodeJS

Previous
Next Post »