nodejs read/write file

 

 

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

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。