fs.appendFile()

fs.appendFile(file, data[, options], callback)

Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer.

Example:

fs.appendFile('message.txt', 'data to append', (err) => {
  if (err) throw err;
  console.log('The "data to append" was appended to file!');
});

If options is a string, then it specifies the encoding. Example:

fs.appendFile('message.txt', 'data to append', 'utf8', callback);

Any specified file descriptor has to have been opened for appending.

Note: Specified file descriptors will not be closed automatically.

doc_Nodejs
2016-04-30 04:39:38
Comments
Leave a Comment

Please login to continue.