fs.readFile(path[, options], callback)

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的更多相关文章

  1. 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" ...

  2. NodeJs FS 文件系统模块

    1. fs.stat 检测是文件还是目录 fs.stat('html',function(err,stats){ if(err){ console.log(err); return false; } ...

  3. nodejs - fs模块 - 文件操作

    1, fs.stat  检测是文件还是目录 2, fs.mkdir 创建目录 var fs = require('fs') fs.mkdir('./dir',function(err){ if(err ...

  4. nodejs fs 模块

    件系统操作相关的函数挺多的.首先可以分为两大类. 一类是异步+回调的. 一类是同步的. 在这里只对异步的进行整理,同步的只需要在函数名称后面加上Sync即可 1. 首先是一类最常规的读写函数,函数名称 ...

  5. nodejs fs 模块的用途

    /*** New node filefs 操作*/var fs = require(“fs”); /*创建文件 var fileName = “anps_hsj”;fs.mkdir(fileName, ...

  6. nodejs fs path

    内容详见我的gitHub: https://github.com/shangyueyue/ssy-utils/tree/master/src/nodejs/fs

  7. NodeJs Fs模块

    和前面的Http.Url模块一样,Fs模块也是node的核心模块之一,主要用于对系统文件及目录进行读写操作. 基本方法 fs.stat fs.stat可以用来判断是文件还是目录:stats.isFil ...

  8. nodejs fs学习

    在本章的开始,我本来只想写一些关于fs模块的内容,虽然这个模块包含的方法非常的多,但没有想到的是它和我们上一篇文章Node.js Buffer还存在着关联,所以我又把关于Buffer的内容简单的学习下 ...

  9. nodejs fs路径

    引用:https://www.cnblogs.com/guangzhou11/p/7705257.html require()别的js文件的时候,将执行那个js文件. 注意: require()中的路 ...

随机推荐

  1. 一、@Html.DropDownList

    一.Html.DropDownList 通过linq 将datatable转换下拉列表 //查询城市 string CityId = WebCommon.Public.GetAdminCityId() ...

  2. ICU lirary DownLoad

    { //https://github.com/unicode-org/icu }

  3. 【InnoDB】缓冲池

    索引目录 INNODB的体系结构 缓冲池 缓存中页的定位: checkpoint技术 INNODB的关键特性 插入缓冲 change buffer 两次写 以下的资料总结自:官方文档和<MySQ ...

  4. redis requires Ruby version >= 2.2.2.

    安装RVM 无法在服务器使用curl命令访问https域名,原因是nss版本有点旧了,yum -y update nss更新一下 yum -y update nss 新建rvm-installer.s ...

  5. 自己封装 vue 组件 和 插件

    vue 组件 一.组件的创建,两种方法.(本质上是1.2两种,vue文件,只是创建了一个  组件选项对象,仅是一个js对象)1.定义组件:Vue.component('button-counter', ...

  6. Redis入门很简单之五【Jedis和Spring的整合】

    Redis入门很简单之五[Jedis和Spring的整合] 博客分类: NoSQL/Redis/MongoDB redisnosql缓存jedisspring  在上一篇文章中,简单介绍了Jedis的 ...

  7. NLayer Architecture in abp

    https://aspnetboilerplate.com/Pages/Documents/NLayer-Architecture Introduction The layering of an ap ...

  8. 8、数值分析与matlab

    1.今天要拷matlab代码了,而且是很恶心的算法,估计也没几个人能看得懂,就连我自己都看不懂. 我也不知道这样做的意义何在,可能只是证明我在这世上曾经学过那么那么难的东西吧 首先是一个matlab版 ...

  9. memcached 安装与简单实用使用

    一.简介 1.memcache与memcached的区别与联系: memcache是php的拓展,memcached是客户端,复杂的说:Memcache模块提供了于memcached方便的面向过程及面 ...

  10. 安装graphviz

    环境win10 1. 下载安装包首先进入官网下载msi文件 安装,一路next,不需要注意什么 2.设置环境变量 安装完毕之后,我们需要手动配置环境变量. 找到刚才我们安装地址,进入graphviz, ...