const fs = require('fs');
const data = '菜鸟教程';

const writeStream = fs.createWriteStream('output.txt');

writeStream.write(data,'UTF8');

writeStream.end();

writeStream.on('finish',()=>{
  console.log('写入完成');
});

writeStream.on('error',(err)=>{
  console.log(err.stack);
});

const readerStream = fs.createReadStream('input.txt');
const writeStream2 = fs.createWriteStream('copy.txt');
readerStream.pipe(writeStream2);


console.log('程序执行完毕');