Created
April 24, 2010 15:53
-
-
Save polotek/377732 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Simple example of using fs methods to append to a file | |
*/ | |
var sys = require('sys'), | |
fs = require('fs'); | |
fs.open('my.log', 'a', undefined, function(err, fd) { | |
if(err) throw err; | |
fs.write(fd, 'Appending to this file\n', undefined, undefined, function(err, written) { | |
if(err) throw err; | |
sys.puts(written + ' bytes written'); | |
fs.close(fd, function(err) { | |
if(err) throw err; | |
fs.readFile('my.log', function(err, data) { | |
if(err) throw err; | |
sys.puts(data); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment