用java代码实现两个linux服务器文件的互相拷贝,Java实现文件拷贝

这篇博客展示了对不同大小文件进行复制操作时,使用多种方法(如Mbb、NIO TransferFrom/To、BufferRead、FastBufferRead和Stream)的性能对比。实验结果显示,缓冲区大小对某些方法的性能有显著影响,尤其是在处理大文件时。例如,对于42MB和350MB的文件,适当增加缓冲区大小可以明显提高复制速度。
摘要由CSDN通过智能技术生成

测试结果

File :G:/from_42MB.rar ---- Buffer Size : 1024--------------

coypByMbb time consumed(buffer size no effect) : 47

copyByNioTransferFrom time consumed(buffer size no effect) : 62

copyByNioTransferTo time consumed(buffer size no effect) : 47

coypByBufferRead time consumed(buffer size take effect) : 249

coypByFastBufferRead time consumed(buffer size take effect) : 188

coypByStream time consumed(buffer size take effect) : 187

File :G:/from_42MB.rar ---- Buffer Size : 4096--------------

coypByMbb time consumed(buffer size no effect) : 15

copyByNioTransferFrom time consumed(buffer size no effect) : 16

copyByNioTransferTo time consumed(buffer size no effect) : 31

coypByBufferRead time consumed(buffer size take effect) : 125

coypByFastBufferRead time consumed(buffer size take effect) : 79

coypByStream time consumed(buffer size take effect) : 93

File :G:/from_42MB.rar ---- Buffer Size : 10240--------------

coypByMbb time consumed(buffer size no effect) : 16

copyByNioTransferFrom time consumed(buffer size no effect) : 32

copyByNioTransferTo time consumed(buffer size no effect) : 31

coypByBufferRead time consumed(buffer size take effect) : 78

coypByFastBufferRead time consumed(buffer size take effect) : 62

coypByStream time consumed(buffer size take effect) : 63

File :G:/from_350MB.rar ---- Buffer Size : 1024--------------

coypByMbb time consumed(buffer size no effect) : 280

copyByNioTransferFrom time consumed(buffer size no effect) : 453

copyByNioTransferTo time consumed(buffer size no effect) : 7785

coypByBufferRead time consumed(buffer size take effect) : 8144

coypByFastBufferRead time consumed(buffer size take effect) : 7068

coypByStream time consumed(buffer size take effect) : 8503

File :G:/from_350MB.rar ---- Buffer Size : 4096--------------

coypByMbb time consumed(buffer size no effect) : 1904

copyByNioTransferFrom time consumed(buffer size no effect) : 5978

copyByNioTransferTo time consumed(buffer size no effect) : 7379

coypByBufferRead time consumed(buffer size take effect) : 7621

coypByFastBufferRead time consumed(buffer size take effect) : 7474

coypByStream time consumed(buffer size take effect) : 8200

File :G:/from_350MB.rar ---- Buffer Size : 10240--------------

coypByMbb time consumed(buffer size no effect) : 328

copyByNioTransferFrom time consumed(buffer size no effect) : 6864

copyByNioTransferTo time consumed(buffer size no effect) : 7021

coypByBufferRead time consumed(buffer size take effect) : 7199

coypByFastBufferRead time consumed(buffer size take effect) : 7941

coypByStream time consumed(buffer size take effect) : 78010b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值