code: private static void doCopyFile(final File srcFile, final File destFile, final boolean preserveFileDate) {
          if (destFile.exists()) {
              throw new IllegalArgumentException("The destination file already existed: " + destFile.getAbsolutePath());
          }
  
          FileInputStream fis = null;
          FileOutputStream fos = null;
          FileChannel input = null;
          FileChannel output = null;
  
          try {
              fis = new FileInputStream(srcFile);
              fos = new FileOutputStream(destFile);
              input = fis.getChannel();
              output = fos.getChannel();
  
              long size = input.size();
              long pos = 0;
              long count = 0;
  
              while (pos < size) {
                  count = ((size - pos) > FILE_COPY_BUFFER_SIZE) ? FILE_COPY_BUFFER_SIZE : (size - pos);
                  pos += output.transferFrom(input, pos, count);
              }
          } catch (IOException e) {
              throw new UncheckedIOException(e);
          } finally {
              close(output);
              close(fos);
              close(input);
              close(fis);
          }
  
          if (srcFile.length() != destFile.length()) {
              deleteAllIfExists(destFile);
              throw new UncheckedIOException(new IOException("Failed to copy full contents from '" + srcFile + "' to '" + destFile + "'"));
          }
  
          if (preserveFileDate) {
              destFile.setLastModified(srcFile.lastModified());
          }
      }
docs: Internal copy file method.
  
  @param srcFile
  the validated source file, must not be {@code null}
  @param destFile
  the validated destination file, must not be {@code null}
  @param preserveFileDate
  whether to preserve the file date