node fs 文件读取
1、fs.readFile(filename,[encoding],[callback(err,data)])两种用法
(1)var fs = require('fs');
fs.readFile('./jiyu.txt',(err,data)=>{
if(err)
console.log(err);
else
console.log(data);
});
运行结果:
<Buffer e8 bf 99 e6 98 af 6e 6f 64 65 e8 af bb e5 87 ba e6 9d a5 e7 9a 84 e5 86 85 e5 ae b9 e3 80 82>
(2) var fs = require('fs');