Home > Article > Web Front-end > Instructions for using the fs.readSync method in node.js_node.js
Method description:
Synchronized version of fs.read() .
The method will return a bytesRead (the number of bytes read)
Grammar:
Since this method belongs to the fs module, the fs module needs to be introduced before use (var fs= require(“fs”) )
Receive parameters:
fs
buffer The buffer into which data will be written.
offset The offset written to the buffer
length (integer) Specifies the length of the file read in bytes
position (integer) Specifies the starting position of file reading. If this item is null, data will be read starting from the position of the current file pointer.
Example:
Source code: