用Java复制文件的最快方法 [英] Fastest way to copy files in Java

查看:173
本文介绍了用Java复制文件的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用Java复制大量文件的最快方法是什么。到目前为止,我已经使用了文件流和nio。整体流似乎比nio快。到目前为止你有什么经历?

What ist the fastest way to copy a big number of files in Java. So far I have used file streams and nio. Overall streams seem to be faster than nio. What experiences did you make so far?

推荐答案

http://www.baptiste-wicht.com/2010/08/file-copy-in-java-benchmark/ 可能会得到你的答案。

http://www.baptiste-wicht.com/2010/08/file-copy-in-java-benchmark/ might get you your answer.


对于基准测试,我使用不同的文件进行测试。

For the benchmark, I made the tests using different files.


  1. 小文件(5 KB)

  2. 中等文件(50 KB)

  3. 大文件(5 MB)

  4. 胖文件(50 MB)

  5. 一个巨大的文件(1.3 GB)只有二进制文件

  1. Little file (5 KB)
  2. Medium file (50 KB)
  3. Big file (5 MB)
  4. Fat file (50 MB)
  5. And an enormous file (1.3 GB) only binary

我首先使用文本文件然后使用二进制文件进行测试。我使用三种模式进行测试:

And I made the tests first using text files and then using binary files. I made the tests using in three modes :


  1. 在同一硬盘上。这是一个250 GB的IDE硬盘,带有8 MB的缓存。它的格式为Ext4。

  2. 在两个磁盘之间。我使用了第一个磁盘和另一个250 GB的SATA硬盘和16 MB的缓存。它的格式为Ext4。

  3. 在两个磁盘之间。我使用了第一个磁盘和另一个1 TB的SATA硬盘和32 MB的缓存。它使用NTFS格式化。

我使用了基准框架,此处描述,对所有方法进行测试。测试是在我的个人计算机上进行的(Ubuntu 10.04 64位,Intel Core 2 Duo 3.16 GHz,6 Go DDR2,SATA硬盘)。使用的Java版本是Java 7 64位虚拟机......

I used a benchmark framework, described here, to make the tests of all the methods. The tests have been made on my personal computer (Ubuntu 10.04 64 bits, Intel Core 2 Duo 3.16 GHz, 6 Go DDR2, SATA Hard Disks). The Java version used is a Java 7 64 bits Virtual Machine...

这篇关于用Java复制文件的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆