Node.js fs read and write via piped stream
var fs = require('fs'); // Create a readable Stream var readerStream = fs.createReadStream('input.txt'); // Create a writable Stream var writerStream = fs.createWriteStream('outputOfPiping.txt'); // Pipe the read and write operations // read input.txt and write data to output.txt readerStream.pipe(writerStream);/*from ww w.ja va 2 s . co m*/ console.log('Finish Piping');