Created
January 3, 2013 09:45
-
-
Save takaheraw/4442262 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 filepath = path.join(__dirname, 'test.txt'); | |
var readStream = fs.createReadStream(filepath, {bufferSize:4}); | |
readStream.setEncoding('utf8'); | |
readStream.on('data', function(data){ | |
console.log(data); | |
}); | |
readStream.on('end', function(){ | |
console.log('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