fs.readFile(file[, options], callback)
Asynchronously reads the entire contents of a file. Example:
fs.readFile('/etc/passwd', (err, data) => { if (err) throw err; console.log(data); });
The callback is passed two arguments (err, data)
, where data
is the contents of the file.
If no encoding is specified, then the raw buffer is returned.
If options
is a string, then it specifies the encoding. Example:
fs.readFile('/etc/passwd', 'utf8', callback);
Any specified file descriptor has to support reading.
Note: Specified file descriptors will not be closed automatically.
Please login to continue.