在node.js中复制文件的最快方法

在node.js中复制文件的最快方法,第1张

在node.js中复制文件的最快方法

这是使用流在一行代码中复制文件的好方法:

var fs = require('fs');fs.createReadStream('test.log').pipe(fs.createWriteStream('newLog.log'));

在节点v8.5.0中,添加了copyFile

const fs = require('fs');// destination.txt will be created or overwritten by default.fs.copyFile('source.txt', 'destination.txt', (err) => {  if (err) throw err;  console.log('source.txt was copied to destination.txt');});


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5427480.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-11
下一篇2022-12-11

发表评论

登录后才能评论

评论列表(0条)

    保存