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();
FileChannel toChannel = toFile.getChannel();
long position = 0; www.2cto.com
long count = fromChannel.size();
fromChannel.transferTo(position, count,toChannel);
}
}
作者:rjgcx2