filehandle.readFile(options)
-
-
signal
<AbortSignal> 允许中止正在进行的 readFile¥
signal
<AbortSignal> allows aborting an in-progress readFile
-
返回:<Promise> 成功读取时将使用文件内容履行。如果未指定编码(使用
options.encoding
),则数据作为 <Buffer> 对象返回。否则,数据将为字符串。¥Returns: <Promise> Fulfills upon a successful read with the contents of the file. If no encoding is specified (using
options.encoding
), the data is returned as a <Buffer> object. Otherwise, the data will be a string.
异步地读取文件的全部内容。
¥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.