This article mainly introduces node. fs. the createWriteStream method is described in this article. createWriteStream method description, syntax, receiving parameters, use instances, and implementation source code. For more information, see
Method description:
Returns a WriteStream (output stream) object (writable stream ).
Syntax:
The 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:
The 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:
The Code is as follows:
Fs. createWriteStream = function (path, options ){
Return new WriteStream (path, options );
};