介紹ui
文件流spa
var fs = require('fs') var rs = fs.createReadStream('./a.txt') var ws = fs.createWriteStream('./hello.txt', { flags: 'a' }) rs.once('open', function () { console.log('可讀流打開了') }) rs.once('close', function () { console.log('可讀流關閉了') ws.end() }) rs.on('data', function (data) { ws.write(data) }) ws.once('open', function () { console.log('可寫流打開了') }) ws.once('close', function () { console.log('可寫流關閉了') })
var fs = require('fs') var rs = fs.createReadStream('./a.txt') var ws = fs.createWriteStream('./hello.txt', { flags: 'a' }) rs.once('open', function () { console.log('可讀流打開了') }) rs.once('close', function () { console.log('可讀流關閉了') // ws.end() }) // rs.on('data', function (data) { // ws.write(data) // }) ws.once('open', function () { console.log('可寫流打開了') }) ws.once('close', function () { console.log('可寫流關閉了') }) rs.pipe(ws)