public void TestTransferFrom() {
try {
RandomAccessFile raf = new RandomAccessFile("C:\\Users\\Hajon\\Downloads\\apache-maven-3.3.9-bin.zip", "rw");
FileChannel fromChannel=raf.getChannel();
RandomAccessFile raf1 = new RandomAccessFile("C:\\Users\\Hajon\\Downloads\\apache-maven-3.3-bin.zip", "rw");
FileChannel toChannel=raf.getChannel();
long position=0;
long size=fromChannel.size();
System.out.println(size);
toChannel.transferFrom(fromChannel, position, size);
raf.close();
raf1.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
执行完后的复制结果都是空的怎么回事