有一个文件 'foo.txt' 写有 'koushik'。代码:-
var fs = require('fs');
var rr = fs.createReadStream('foo.txt');
rr.on('readable', function() {
console.log('readable:', rr.read(1));
});
rr.on('end', function() {
console.log('end');
});
输出:-
k
o