1. 使用fs模塊
var fs = require("fs");
2. 讀取
fs.readFile("test.txt", 'utf-8', (err, data) => {
if (err) throw err;
console.log(data)
});
3. 寫入
fs.writeFile("test.txt", "我寫入了一句話", (err, data) => {
if (err) throw err;
});
4. 追加
fs.appendFile("test.txt", "我寫入了一句話", (err, data) => {
if (err) throw err;
});