Fastest way to copy files in Java

后端 未结 6 1026
萌比男神i
萌比男神i 2021-02-07 01:32

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 mak

6条回答
  •  野的像风
    2021-02-07 01:53

    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. 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. On the same hard disk. It's an IDE Hard Disk of 250 GB with 8 MB of cache. It's formatted in Ext4.
    2. Between two disk. I used the first disk and an other SATA Hard Disk of 250 GB with 16 MB of cache. It's formatted in Ext4.
    3. Between two disk. I used the first disk and an other SATA Hard Disk of 1 TB with 32 MB of cache. It's formatted using NTFS.

    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...

提交回复
热议问题