nodejs read/write file

zyip發表於2014-12-05

 

 

fs.readFile('c:\\tmp\\helloworld.txt','utf8',function(err,data){console.log(data);})

  

 var token=fs.readFileSync('c:\\tmp\\toekn.txt','utf8');

  

 

fs.writeFile('c:\\tmp\\helloworld.txt', 'Hello World! now, hello again!')

  

fs.exists('c:\\tmp\\helloworld.txt',function(exists){console.log(exists);})

  

fs.existsSync('c:\\tmp\\helloworld.txt')

  

http://nodejs.org/api/fs.html#fs_fs_exists_path_callback

https://docs.nodejitsu.com/articles/file-system/how-to-read-files-in-nodejs

 

相關文章