open
‘open(string path, string/Object parameters)’ (Stream)
The parameter object can contain :
- mode: Open Mode. A string made of ‘r’, ‘w’, ‘a/+’, ‘b’ characters.
- charset : An IANA, case insensitive, charset name.
Stream objects are returned from the fs.open method. Don’t forget to close the stream.
When errors occur during a call, it will throw a ‘Unable to open file PATH’ and hang execution.
Examples
var fs = require('fs');
var file = fs.open('/path/to/file', 'r'); //Open Mode. A string made of 'r', 'w', 'a/+', 'b' characters.
var otherFile = fs.open('/path/to/otherFile', {
mode: 'r' //(see Open Mode above)
});
var yetAnotherFile = fs.open('/path/to/yetAnotherFile', {
mode: 'w', //(see Open Mode above)
charset: 'US-ASCII' //An IANA, case insensitive, charset name.
});
file.close();
otherFile.close();
yetAnotherFile.close();