MappedFileCopy.java

import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class MappedFileCopy {
  public static void main(String[] args) throws IOException {
    FileInputStream fIn = new FileInputStream(args[0]);
    FileOutputStream fOut = new FileOutputStream(args[1]);
    FileChannel cIn = fIn.getChannel();
    FileChannel cOut = fOut.getChannel();
    try {
      MappedByteBuffer bIn =
    cIn.map(FileChannel.MapMode.READ_ONLY,0,cIn.size());
      cOut.write(bIn);
    } finally {
      cIn.close();
      cOut.close();
    }
  }
}