Introduction
Description
Description
Example
Description
Example writableStreamm.write() fucntion as shown.
In order to know whether the files have been written or not the emitted events by stream should be given with listeners as shown below.
[c]
var fs = require('fs');
var writableStream = fs.createWriteStream('output1.txt');
writableStream.on('finish', function () {
console.log('Done');
});
writableStream.write('Node.js Tutorials\n');
writableStream.write('My first "Writable Stream" example\n');
writableStream.end(function () {
console.log('Successfully written the file');
});
[/c]
From the above code, the finish event flushes the entire data into system and display a message Compiling the above code will produce the output as shown below.
Now, check the file output1.txt file in the directory and the file should be written with the text as shown below.
Description
Example
Result
Description
Example
Description
Description
Key Points