import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;
public class MainClass {
public static void main(String[] args) throws Exception {
FileChannel in = new FileInputStream("source.txt").getChannel(), out = new FileOutputStream(
"target.txt").getChannel();
in.transferTo(0, in.size(), out);
// Or:
// out.transferFrom(in, 0, in.size());
}
}
|