当前位置:网站首页>Nodejs (four) character reading
Nodejs (four) character reading
2022-04-23 07:47:00 【youth who behaves like an adult】
console.log("ssss");
var fs=require("fs");
var re=fs.createReadStream("Test.txt",{highWaterMark:7});
re.setEncoding('utf8');
var texts="";
re.on("data",function(chunk){
texts+=chunk;
});
re.on("end",function(){
console.log(texts);
});
console.log("5555");
1. The compilation method is different when reading data , There will be garbled code ,re.setEncoding('utf8'); Specifying the encoding method can avoid problems
var fs=require("fs");
var re=fs.createReadStream("Test.txt",{highWaterMark:7});
var xxx=[];
var size=0;
re.on("data",function(chunk){
xxx.push(chunk);
size += chunk.length;
});
re.on("end",function(){
var text=Buffer.concat(xxx,size);
console.log(text.toString());
});
console.log("5555");
2. When reading data, you can cache it first , The final splicing
版权声明
本文为[youth who behaves like an adult]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230626191056.html
边栏推荐
- Date object (JS built-in object)
- C#使用拉依达准则(3σ准则)剔除异常数据(.Net剔除一组数据中的奇异值)
- Samplecamerafilter
- SAP RFC_CVI_EI_INBOUND_MAIN BP主数据创建示例(仅演示客户)
- SAP TRANSLATE使用数据对象掩码示例
- The difference and application of VR, AR and MR, as well as some implementation principles of AR technology
- Two threads print odd and even numbers interactively
- js之DOM学习三种创建元素的方式
- 面经的总结
- SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)
猜你喜欢
利用Lambda表达式解决c#文件名排序问题(是100大还是11大的问题)
FSM finite state machine
Implementation of MySQL persistence
Redis connection error err auth < password > called without any password configured for the default user
设置了body的最大宽度,但是为什么body的背景颜色还铺满整个页面?
canvas学习第一篇
Apache Hudi 如何加速传统的批处理模式?
对复杂字典Dictionary<T1,T2>排序问题
ABAP CDS VIEW WITH ASSOCIATION示例
Window10版MySQL设置远程访问权限后不起效果
随机推荐
url转成对象
ES6使用递归实现深拷贝
NodeJS(六) 子进程操作
ABAP 实现发布RESTful服务供外部调用示例
Learn to use search engines
js之DOM学习三种创建元素的方式
'NPM' is not an internal or external command, nor is it a runnable program or batch file
RGB颜色转HEX进制与单位换算
Use of command line parameter passing library argparse
取得所有点列表中的最大值GetMaxPoint
js之函数的两种声明方式
颜色转换公式大全及转换表格(31种)
C# SmoothProgressBar自定义进度条控件
NodeJS(一) 事件驱动编程
keytool: command not found
层次输出二叉树
SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)
H5 local storage data sessionstorage, localstorage
Processing of common dependency module
MySQL storage engine