import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
public class Copy {
public static void main(String [ ] args) throws IOException {
RandomAccessFile fromFile = new RandomAccessFile("fromFile.txt", "rw");
FileChannel fromChannel = fromFile.getChannel();
RandomAccessFile toFile = new RandomAccessFile("toFile.txt", "rw");
FileChannel toChannel = toFile.getChannel();
long position = 0;
long count = fromChannel.size();
fromChannel.transferTo(position, count,toChannel);
}
}
java nio copy file
最新推荐文章于 2023-12-30 22:11:25 发布