const fs = require('fs')
let readStream = fs.createReadStream('文件位置/文件名')
let c = 0
readStream.on('data',(data)=>{
console.log(data)
c++
})
readStream.on('end',()=>{
console.log(c)
})
readStream.on('error',(err)=> {
console.log(err)
})
const fs = require('fs')
let s = ''
for (let i =0;i<500;i++){
s+='我是大数据\n'
}
let writeStream = fs.createWriteStream('文件位置/文件名')
writeStream.write(s)
writeStream.end()
writeStream.on('finish',()=>{
console.log('写入完成')
})
let readStream = fs.createReadStream('文件位置/文件名')
let writeStream = fs.createWriteStream('文件位置/文件名')
readStream.pipe(writeStream)