Skip to content

Instantly share code, notes, and snippets.

@heapwolf
Created August 7, 2012 22:31
Show Gist options
  • Save heapwolf/3290078 to your computer and use it in GitHub Desktop.
Save heapwolf/3290078 to your computer and use it in GitHub Desktop.
fs/write
var fs = require('fs');
fs.open('./my_file_2.txt', 'a', function opened(err, fd) {
if (err) { throw err; }
var writeBuffer = new Buffer('writing this string'),
bufferPosition = 0,
bufferLength = writeBuffer.length, filePosition = null;
fs.write(fd, writeBuffer, bufferPosition, bufferLength, filePosition,
function wrote(err, written) {
if (err) { throw err; }
console.log('wrote ' + written + ' bytes');
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment