fs.read(fd, buffer, offset, length, position, callback)
-
fd<integer> -
buffer<Buffer> | <TypedArray> | <DataView> 数据将写入的缓冲区。¥
buffer<Buffer> | <TypedArray> | <DataView> The buffer that the data will be written to. -
offset<integer> 要写入数据的buffer中的位置。¥
offset<integer> The position inbufferto write the data to. -
length<integer> 读取的字节数。¥
length<integer> The number of bytes to read. -
position<integer> | <bigint> | <null> 指定从文件中开始读取的位置。如果position为null或-1,则将从当前文件位置读取数据,并更新文件位置。如果position是整数,则文件位置将保持不变。¥
position<integer> | <bigint> | <null> Specifies where to begin reading from in the file. Ifpositionisnullor-1, data will be read from the current file position, and the file position will be updated. Ifpositionis an integer, the file position will be unchanged. -
callback<Function>
从 fd 指定的文件中读取数据。
¥Read data from the file specified by fd.
回调被赋予三个参数,(err, bytesRead, buffer)。
¥The callback is given the three arguments, (err, bytesRead, buffer).
如果未同时修改文件,当读取的字节数为零时,则到达文件末尾。
¥If the file is not modified concurrently, the end-of-file is reached when the number of bytes read is zero.
如果此方法作为其 util.promisify() 版本被调用,则返回具有 bytesRead 和 buffer 属性的 Object 的 promise。
¥If this method is invoked as its util.promisify()ed version, it returns
a promise for an Object with bytesRead and buffer properties.