fs.writeFileSync("sam.txt","data is content"); always write proper content , dont write byte code , so it means writeFile and WriteFileSync dont care about the encoding mode.
-
noob
Jan 19 '17 04:32
console.log(fs.readFileSync('file.txt','utf8'));//utf8 encoding
console.log(fs.readFileSync('file.txt','binary'));//binary encoding
console.log(fs.readFileSync('file.txt','ascii'));//ascii encoding
var fs=require('fs');
fs.readFile(filePath, 'utf8', getFile );
function getFile (error, fileContent) {
if (error) return callback(error)
console.log(fileContent);
}
var fs=require('fs');
fileContent=fs.readFileSync(filePath, 'utf8');
fs.readFile(filePath, 'utf8', callback);
fs.readFileSync(filePath).toString();