code: public static void copyFile(final File src, final File dest)
              throws IOException {
          if (src == null || !src.canRead()) {
              throw new InvalidArgument("src", src);
          }
  
          if (dest == null || !dest.canWrite()) {
              throw new InvalidArgument("dest", dest);
          }
  
          // initialize streams/channels
          FileInputStream srcInput = null;
          FileChannel srcChannel = null;
          FileOutputStream destOutput = null;
          FileChannel destChannel = null;
          try {
              srcInput = new FileInputStream(src);
              srcChannel = srcInput.getChannel();
              destOutput = new FileOutputStream(dest);
              destChannel = destOutput.getChannel();
  
              // transfer from src to dest channel, one megabyte at a time
              long size = srcChannel.size();
              long pos = 0;
              long count = 0;
              while (pos < size) {
                  count =
                          (size - pos) > ONE_MEGABYTE ? ONE_MEGABYTE
                                  : (size - pos);
                  pos += destChannel.transferFrom(srcChannel, pos, count);
              }
          } finally {
              // close channels and streams
              if (destChannel != null) {
                  destChannel.close();
              }
              if (destOutput != null) {
                  destOutput.close();
              }
              if (srcChannel != null) {
                  srcChannel.close();
              }
              if (srcInput != null) {
                  srcInput.close();
              }
          }
      }
docs: Copies a {@link File source file} to a {@link File destination file}.
  
  @param src the {@link File source file}, which must be non-null and
  readable
  @param dest the {@link File destination file}, which must be non-null and
  writable
  @throws IOException Thrown if an IO error occurred copying the
  {@link File src} to {@link File dest}
  @throws InvalidArgument Thrown if
  <ul>
  <li>{@code src} or {@code dest} is {@code null}</li>
  <li>{@code src} is not readable</li>
  <li>{@code dest} is not writeable</li>
  </ul>