Node.JS文件系統(tǒng)解析實例詳解
更新時間:2017年05月15日 08:32:30 作者:ganchuanpu
這篇文章主要介紹了Node.JS文件系統(tǒng)解析實例詳解的相關(guān)資料,需要的朋友可以參考下
1.Node.js 文件系統(tǒng)
var fs = require("fs")
2.異步和同步
讀取文件內(nèi)容的函數(shù)有異步的 fs.readFile() 和同步的 fs.readFileSync()。
var fs = require('fs')
fs.readFile( 'a.txt','utf-8', function (err,data) {
if( err )
{
console.error(err)
}else{
console.log( "not aynsc===>" + data )
}
})
console.log('app started')
var rlt = fs.readFileSync('a.txt')
console.log('rlt====>'+ rlt )
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
node.js中的http.response.writeHead方法使用說明
這篇文章主要介紹了node.js中的http.response.writeHead方法使用說明,本文介紹了http.response.writeHead的方法說明、語法、接收參數(shù)、使用實例和實現(xiàn)源碼,需要的朋友可以參考下2014-12-12
Puppeteer 爬取動態(tài)生成的網(wǎng)頁實戰(zhàn)
這篇文章主要介紹了Puppeteer 爬取動態(tài)生成的網(wǎng)頁實戰(zhàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-11-11
module.exports和exports使用誤區(qū)案例分析
module.exports和exports使用誤區(qū),使用require()模塊時,得到的永遠都是module.exports指向的對象2023-04-04

