filehandle.readFile(options)


  • options <Object> | <string>
  • 返回值:<Promise> 在成功读取文件内容时完成。如果未指定编码(使用 options.encoding),数据将以 <Buffer> 对象的形式返回。否则,数据将是一个字符串。

异步地读取文件的全部内容。

【Asynchronously reads the entire contents of a file.】

如果 options 是一个字符串,那么它指定了 encoding

【If options is a string, then it specifies the encoding.】

<FileHandle> 必须支持阅读。

【The <FileHandle> has to support reading.】

如果对一个文件句柄调用一次或多次 filehandle.read(),然后再调用 filehandle.readFile(),数据将从当前位置读取到文件末尾。它并不总是从文件开头开始读取。

【If one or more filehandle.read() calls are made on a file handle and then a filehandle.readFile() call is made, the data will be read from the current position till the end of the file. It doesn't always read from the beginning of the file.】