let fs =require("fs");let paht =require("path");
fs.open(paht.join(__dirname,"a.txt"),"w",(err,fd)=>{ let buf = Buffer.from("天蓝蓝·海蓝蓝"); /* * buf 指的是读取的buffer * 0 从buffer哪个位置读取 * 4 读取多少个buffer往里写 * 0 从文件哪个位置写入 * bytesWritten实际写入的个数 * */ fs.write(fd,buf,0,4,0,(err,bytesWritten)=>{ console.log("写入成功") });});
原文地址:https://www.cnblogs.com/liujzcom/p/9521185.html
时间: 2024-10-10 10:25:52