Node.js Problem While Reading File
I'm trying to do write text end of the file.And read it from the end.Or write it to end,then read it from there but when i try to write with r+ all text deleted.While I m reading it with a+ it does not read from the end or i m making a mistake
var http = require('http');
var fs = require('fs');
var log = fs.createWriteStream('message.txt', {'flags': 'a'});
log.write('I want all of us money back');
var a = fs.createReadStream('message.txt', {'flags': 'a+',encoding:'utf8'});
a.on('data'开发者_JAVA百科,function(data)
{
console.log(data);
});
Is there a way to set it. I found it jquery get reverse but it's better to found a way from terminal.
It looks like what you are doing is the same thing as the functionality of the Stream.pipe function, so I suggest reading that documentation and using stream.pipe directly. However, I suspect the problem in your code is you are writing to the stream but then reading from it before the data that was written is actually flushed (meaning it is still being buffered by the OS).
精彩评论