nodejs fs.readFile
fs.readFile(path[, options], callback)
path
<string> | <Buffer> | <URL> | <integer> 文件名或文件描述符。options
<Object> | <string>callback
<Function>
demo
02.js
var fs=require("fs"); fs.readFile('test.txt',function (err,data) {
if (err ) {
console.log("读取失败")
} else {
//输出test.txt的内容
console.log(data.toString());
} });
test.txt
how are you
you are good
输出结果:
nodejs fs.readFile的更多相关文章
- nodejs -- fs模块 ---> readFile 函数 1) fs.readFile(filename, "binary", function(error, file) 2) response.write(file, "binary");
一:代码: 1.1 入口文件: index.js var server = require('./server'); var router = require("./router" ...
- NodeJs FS 文件系统模块
1. fs.stat 检测是文件还是目录 fs.stat('html',function(err,stats){ if(err){ console.log(err); return false; } ...
- nodejs - fs模块 - 文件操作
1, fs.stat 检测是文件还是目录 2, fs.mkdir 创建目录 var fs = require('fs') fs.mkdir('./dir',function(err){ if(err ...
- nodejs fs 模块
件系统操作相关的函数挺多的.首先可以分为两大类. 一类是异步+回调的. 一类是同步的. 在这里只对异步的进行整理,同步的只需要在函数名称后面加上Sync即可 1. 首先是一类最常规的读写函数,函数名称 ...
- nodejs fs 模块的用途
/*** New node filefs 操作*/var fs = require(“fs”); /*创建文件 var fileName = “anps_hsj”;fs.mkdir(fileName, ...
- nodejs fs path
内容详见我的gitHub: https://github.com/shangyueyue/ssy-utils/tree/master/src/nodejs/fs
- NodeJs Fs模块
和前面的Http.Url模块一样,Fs模块也是node的核心模块之一,主要用于对系统文件及目录进行读写操作. 基本方法 fs.stat fs.stat可以用来判断是文件还是目录:stats.isFil ...
- nodejs fs学习
在本章的开始,我本来只想写一些关于fs模块的内容,虽然这个模块包含的方法非常的多,但没有想到的是它和我们上一篇文章Node.js Buffer还存在着关联,所以我又把关于Buffer的内容简单的学习下 ...
- nodejs fs路径
引用:https://www.cnblogs.com/guangzhou11/p/7705257.html require()别的js文件的时候,将执行那个js文件. 注意: require()中的路 ...
随机推荐
- 在eclipse中添加svn插件
1.点击菜单栏中的help选项,然后选择Install New Software,然后点击ADD,输入: name:subclipse url:http://subclipse.tigris. ...
- Codeforces 669E cdq分治
题意:你需要维护一个multiset,支持以下操作: 1:在某个时间点向multiset插入一个数. 2:在某个时间点在multiset中删除一个数. 3:在某个时间点查询multiset的某个数的个 ...
- 人脸识别课件需要安装的python模块
Python3.6安装face_recognition人脸识别库 https://www.jianshu.com/p/8296f2aac1aa
- 用私有构造器或者枚举类型强化SingleTon(单例)属性
单例(singleton)就是一个只实例化一次的类.使类成为单例可能会使它的测试变得困难,因为除非它实现了作为其类型的接口,否则不可能用模拟实现来代替这个单例.下面是几种实现单例的方法: 1.共有静态 ...
- 说一说Vuex有哪几种状态和属性
vuex的流程 页面通过mapAction异步提交事件到action.action通过commit把对应参数同步提交到mutation mutation会修改state中对应的值.最后通过getter ...
- translation of 《deep learning》 Chapter 1 Introduction
原文: http://www.deeplearningbook.org/contents/intro.html Inventors have long dreamed of creating mach ...
- An Easy Introduction to CUDA C and C++
An Easy Introduction to CUDA C and C++ This post is the first in a series on CUDA C and C++, which i ...
- redis相关笔记(二.集群配置及使用)
redis笔记一 redis笔记二 redis笔记三 1.配置:在原redis-sentinel文件夹中添加{8337,8338,8339,8340}文件夹,且复制原8333中的配置 在上述8333配 ...
- Docker 镜像添加模块
Docker 镜像添加模块 1. 使用root用户进入一个新容器,不要用 --rm .否则退出容器的时候,容器没有了 docker run --user 0 -it --name superman ...
- uni-app获取元素宽高封装
getElSize(id) { //得到元素的size return new Promise((res, rej) => { uni.createSelectorQuery().select(' ...