Fastest way to copy files in Java

后端 未结 6 1024
萌比男神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:40

    You can use either FileUtils implementation of apache commons-io library to copy file

    FileUtils.copyFile(new File(sourcePath), new File(destPath));
    

    Which uses FileChannel for IO operation.

    Or use java.nio.file.Files's copy() method.

提交回复
热议问题