I want to read file but if file not available on particular path than gives an error.I want to create a file if not exist and get data value is null. I used these code but not working please any one help me?
fs.readFile(path, 'utf8', function (err,data) {
if (err) {
return console.log(err); //Here throw error if not available
}
console.log(data);
fileData = data;
});
I used below code it's also not working.I want read all data from file what should i put on '?' in following code?
fs.open(path, 'w+', function(err, data) {
if (err) {
console.log("ERROR !! " +err);
} else {
fs.read(data, ? , 0, ? , null, function(err) {
if (err) console.log("ERROR !! " +err);
});
}
});