Created
January 3, 2013 09:53
-
-
Save takaheraw/4442303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'), | |
fs = require('fs'); | |
var outputFilePath = path.join(__dirname, 'write.txt'); | |
var writeStream = fs.createWriteStream(outputFilePath); | |
var inputFilePath = path.join(__dirname, 'test.txt'); | |
var readStream = fs.createReadStream(inputFilePath); | |
writeStream.on('pipe', function(){ | |
console.log('a readableStream pipes writeStream'); | |
}); | |
writeStream.on('error', function(err){ | |
console.log('An error occured'); | |
console.log(err); | |
}); | |
writeStream.on('close', function(){ | |
console.log('writable stream closed'); | |
}); | |
readStream.pipe(writeStream); | |
readStream.on('data', function(data){ | |
console.log('>> a data event occured.'); | |
}); | |
readStream.on('end', function(){ | |
console.log('read end'); | |
}); | |
readStream.on('error', function(err){ | |
console.log('An error occured'); | |
console.log(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment