Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 394 Bytes

180703.md

File metadata and controls

20 lines (17 loc) · 394 Bytes

node:文件模块

异步写入文件

fs.writeFile(file, data[, options], callback)

fs.writeFile('1111.txt', 'Node.js', (err) => {
  if (err) throw err;
  console.log('文件已保存!');
});

异步地读取一个文件的全部内容

fs.readFile(path[, options], callback)

fs.readFile('111.txt', (err, data) => {
  if (err) throw err;
  console.log(data);
});