一、读取文件
1.异步:
fs.readFile("./yes.txt","utf8",function(err,data){
if(err) thorw err;
console.log(data);
});
2.同步
data=fs.readFile("./yes.txt","utf8");
console.log(data):
二、写文件
fs.writeFile("./yes.txt","hahahahhha",function (err,data){
if(err) thorw err;
console.log(data);
}
三、文件追加
fs.appendFile("./yes.txt","xixxiiigahahha",function (err,data){
if(err) thorw err;
console.log(data);
}
四、拷贝文件
fs.copyFile("./yes.txt","./ok.txt",function (err,data){
if(err) thorw err;
console.log(data);
}