fs
读取文件的方式
同步 fs.readFileSync(“path”,“utf-8”) 异步
fs.readFile(path,‘utf-8’,(err,data)=>{})
流 fs.createReadStream(path)rs.on("data",(thunk)=>{ } rs.on("end",callback)
Promise可以解决"回调地狱"
fs http
fs.createReadStream(“文件的路径”).pipe(res)
写入文件的三种方式
同步方式 fs.writeFileSync
异步方式 fs.writeFile
流的方式 fs.createWriteStream 写入完成发生 finish事件
追加内容用appendFileSync appendFile