Method description:
Synchronous version of fs.readFile().
grammar:
The code copy is as follows:
fs.readFileSync(filename, [encoding])
Since this method belongs to the fs module, it is necessary to introduce the fs module before use (var fs= require("fs") )
Receive parameters:
filename file path
options option object, including encoding, encoding format, this item is optional.
example:
The code copy is as follows:
var fs = require('fs');
var contentText = fs.readFileSync('123.txt','utf-8');
console.log(contentText);