Signed-off-by: 陈银军 <yinjun.chen1@gientech.com>
This commit is contained in:
陈银军
2026-08-29 23:37:43 +08:00
parent d4fd5fd903
commit b47cb98c6f
3 changed files with 29 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
const fs = require('fs')
const writeStream = fs.createWriteStream('./output.txt')
writeStream.write('hello world!')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
writeStream.write('hello world!\n')
// end(): 等待缓冲区数据全部写完后再关闭流,触发 finish 事件,再触发 close 事件
writeStream.end()
// close(): 直接关闭流并释放资源,不会等待缓冲区数据写完,可能丢失未写入的数据
writeStream.close()
View File
+11
View File
@@ -0,0 +1,11 @@
hello world!hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!