filehandle.createWriteStream([options])
options
还可以包括 start
选项,以允许在文件开头的某个位置写入数据,允许的值在 [0, Number.MAX_SAFE_INTEGER
] 范围内。
修改文件(而不是替换它)可能需要将 flags
open
选项设置为 r+
(而不是默认的 r
)。
encoding
可以是 <Buffer> 接受的任何一种。
options
<Object>- Returns: <fs.WriteStream>
options
may also include a start
option to allow writing data at some
position past the beginning of the file, allowed values are in the
[0, Number.MAX_SAFE_INTEGER
] range. Modifying a file rather than
replacing it may require the flags
open
option to be set to r+
rather than
the default r
. The encoding
can be any one of those accepted by <Buffer>.
If autoClose
is set to true (default behavior) on 'error'
or 'finish'
the file descriptor will be closed automatically. If autoClose
is false,
then the file descriptor won't be closed, even if there's an error.
It is the application's responsibility to close it and make sure there's no
file descriptor leak.
By default, the stream will emit a 'close'
event after it has been
destroyed. Set the emitClose
option to false
to change this behavior.