1、同步:
var fs = require('fs');console.log('$file starting...');var content = fs.readFileSync('fileTest.txt','utf-8');console.log(content);2、异步:var fs = require("fs");fs.readFile("fileTest.txt",'utf-8',function(err,data){ if(err){ console.log("error"); }else{ console.log(data); }});console.log("Read file async end!");
新闻热点
疑难解答