Node.Js中核心模块之文件系统解析
2016-05-24 14:30
841 查看
测试文件:
/**
* Created by cherish on 2016/5/22.
* 加Sync是同步的,不加是异步的,异步要回调
* fs.readFile(filename,encoding,callback);
*/
var fs=require('fs');
fs.readFile('a.txt','utf-8',function(err,data){
if(err){
console.log(err);
}else{
console.log(data);
}
});
console.log('app started....');
var rlt=fs.readFileSync('a.txt');
console.log('rlt=========>'+rlt);
a.txt:
sssssssssssssssssss
fffffffffffffff
/**
* Created by cherish on 2016/5/22.
* 加Sync是同步的,不加是异步的,异步要回调
* fs.readFile(filename,encoding,callback);
*/
var fs=require('fs');
fs.readFile('a.txt','utf-8',function(err,data){
if(err){
console.log(err);
}else{
console.log(data);
}
});
console.log('app started....');
var rlt=fs.readFileSync('a.txt');
console.log('rlt=========>'+rlt);
a.txt:
sssssssssssssssssss
fffffffffffffff
相关文章推荐
- go和node.js的对比
- Node.JS核心模块之module分析
- 【nodeJS】webstorm中设置nodej智能提示
- MonoDeveloper在windows下中文显示解决方案
- Node.JS核心模块之全局对象和常用工具
- Node.Js上传图片
- 【leetcode】19. Remove Nth Node From End of List
- 《Nodejs开发加密货币》之十五:加密货币就是货币
- selectNode、selectNodeContents 区别
- LeetCode 116. Populating Next Right Pointers in Each Node(右邻)
- LeetCode 117. Populating Next Right Pointers in Each Node II(右邻)
- task2-nodejs 文件处理cheerio群里有不是本学校的人加入,判断一下
- 读书笔记之《深入浅出Node.js》(1)
- express-session(express4.0与express 3.0的区别)
- Node.js简介
- nodejs完整登陆交互
- nodejs模拟get,post 进行字符统计功能
- Node.js的路由跳转的一点理解
- Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateK
- Node.js服务器环境下使用Mock.js拦截AJAX请求的教程