Is this a good way to check file existence and read it (it's a textfile)? People seems to use fs.stat but in the documentation it recommends to use open.
var fs = require('fs');
var readline = require('readline');
var filer = "aaa.bat";
var sr = fs.open(filer, 'r', function(err, fd) {
if (err) {
console.log(err);
return;
}
var rl = readline.createInterface({
input: fs.createReadStream(filer, { fd: fd })
});
rl.on('line', function(data) {
console.log(data);
});
rl.on('close', function() {
});
});
via user8069579
No comments:
Post a Comment