filehandle.read([options])


  • options <Object>
    • buffer <Buffer> | <TypedArray> | <DataView> 一个将被填充读取文件数据的缓冲区。默认值: Buffer.alloc(16384)
    • offset <integer> 开始填充的缓冲区位置。 默认值: 0
    • length <integer> 要读取的字节数。默认值: buffer.byteLength - offset
    • position <integer> | <null> 开始从文件读取数据的位置。如果为 null,数据将从当前文件位置读取,并且位置会被更新。如果 position 是整数,当前文件位置将保持不变。默认值: null
  • 返回:<Promise> 成功时返回一个包含两个属性的对象:

从文件中读取数据,并将其存储在给定的缓冲区中。

【Reads data from the file and stores that in the given buffer.】

如果文件没有被同时修改,当读取的字节数为零时,就到达了文件末尾。

【If the file is not modified concurrently, the end-of-file is reached when the number of bytes read is zero.】