fs.read(fd, buffer, offset, length, position, callback)
fd<integer>buffer<Buffer> | <TypedArray> | <DataView> 数据将要写入的缓冲区。offset<integer> 写入数据到buffer的位置。length<integer> 要读取的字节数。position<integer> | <bigint> | <null> 指定从文件的哪个位置开始读取。如果position为null或-1,数据将从当前文件位置开始读取,并且文件位置会被更新。如果position是一个整数,文件位置将保持不变。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()ed 版本调用此方法,它会返回一个包含 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.