Description of the fs. createWriteStream method in node. js, node. jsfs
Method description:
Returns a WriteStream (output stream) object (writable stream ).
Syntax:
Copy codeThe Code is as follows:
Fs. createWriteStream (path, [options])
Because this method belongs to the fs module, we need to introduce the fs module (var fs = require ("fs") before use "))
Receiving parameters:
Path file path
The option (object) parameter contains the following attributes:
Copy codeThe Code is as follows:
{Flags: 'w ',
Encoding: null,
Mode: 0666}
Option contains a startup option that allows you to write data at the beginning of a file.
The default value of flags is w. If you want to modify a file, instead of replacing it, you need to change flags to R +.
Example:
Copy codeThe Code is as follows:
Fs. createWriteStream = function (path, options ){
Return new WriteStream (path, options );
};