import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;
public class Copy {
public static void main(String[] args) {
FileChannel in = null;
FileChannel out = null;
if (args.length < 2) {
System.out.println("Usage: java Copy <from> <to>");
System.exit(1);
}
try {
in = new FileInputStream(args[0]).getChannel();
out = new FileOutputStream(args[1]).getChannel();
out.transferFrom(in, 0L, (int) in.size());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|