Program:
Output:
var http = require('http'); var fs = require('fs'); var readStream = fs.createReadStream(__dirname+'/demo.txt'); var chuckCounter = 0; readStream.on('data',function(d){ console.log("This is the read data:"+d); chuckCounter++; console.log('\n\n\n'+chuckCounter); }); console.log('\n\n\n'+chuckCounter);
Output: