使用createWriteStream的代码为每次写入创建一个文件描述符。因为它要求节点在写入后立即关闭,因此log.end更好。var fs = require('fs');var logStream = fs.createWriteStream('log.txt', {'flags': 'a'});// use {'flags': 'a'} to append and {'flags': 'w'} to erase and write a new filelogStream.write('Initial line...');logStream.end('this is the end line');