使用FileChannel.map()复制文件
import java.io.IOException;/** 时 代 J a v a - N o w J a v a . c o m 提 供 **/ import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.EnumSet; public class Main { public static void main(String[] args) { Path copy_from = Paths .get("C:/folder1/folder2/folder3/videos/test.mp4"); Path copy_to = Paths.get("C:/test.mp4"); System.out.println("Using FileChannel.map method ..."); try (FileChannel fileChannel_from = (FileChannel.open(copy_from, EnumSet.of(StandardOpenOption.READ))); FileChannel fileChannel_to = (FileChannel .open(copy_to, EnumSet.of(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE)))) { /* 来 自 nowjava.com - 时代Java*/ MappedByteBuffer buffer = fileChannel_f