fs:File System
示例:
//导入文件模块fs
var fs=require("fs");
//读文件
fs.readFile("./in.txt","utf8",(err, data) => {console.log(err);console.log(data);
});
//写文件:若目标文件不存在,则创建之!
fs.writeFile("./out.txt","Im fine, thank you!",err => {if(err!=null){ //成功则err为空,失败则err不为空!console.log(err);return;}console.log("文件写入成功!");
})