import java.io.*;
import java.nio.*;
import java.nio.channels.*;

public class CopyFile
{
  static public void main( String args[] ) throws Exception {
    if (args.length<2) {
      System.err.println( "Usage: java CopyFile source destination" );
      System.exit(1);
    } else {
      FileInputStream fIn = new FileInputStream(args[0]);
      FileOutputStream fOut = new FileOutputStream(args[1]);
      FileChannel canalIn = fIn.getChannel();
      FileChannel canalOut = fOut.getChannel();
      ByteBuffer buffer = ByteBuffer.allocate( 1024 );
      int nombreLu = 0;
      while (nombreLu != -1) {
        buffer.clear();
        nombreLu = canalIn.read( buffer );
        if (nombreLu !=-1) {
          buffer.flip();
          canalOut.write( buffer );
        }
      }
      canalIn.close();
      canalOut.close();
      fIn.close();
      fOut.close();
    }
  }
}
