code: private static void doCopyDirectory(File srcDir, File destDir, FileFilter filter,
        boolean preserveFileDate, List<String> exclusionList) throws IOException {
      // recurse
      File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter);
      if (srcFiles == null) {  // null if abstract pathname does not denote a directory, or if an I/O error occurs
        throw new IOException("Failed to list contents of " + srcDir);
      }
      if (destDir.exists()) {
        if (destDir.isDirectory() == false) {
          throw new IOException("Destination '" + destDir + "' exists but is not a directory");
        }
      } else {
        if (!destDir.mkdirs() && !destDir.isDirectory()) {
          throw new IOException("Destination '" + destDir + "' directory cannot be created");
        }
      }
      if (destDir.canWrite() == false) {
        throw new IOException("Destination '" + destDir + "' cannot be written to");
      }
      for (File srcFile : srcFiles) {
        File dstFile = new File(destDir, srcFile.getName());
        if (exclusionList == null || !exclusionList.contains(srcFile.getCanonicalPath())) {
          if (srcFile.isDirectory()) {
            doCopyDirectory(srcFile, dstFile, filter, preserveFileDate, exclusionList);
          } else {
            doCopyFile(srcFile, dstFile, preserveFileDate);
          }
        }
      }
  
      // Do this last, as the above has probably affected directory metadata
      if (preserveFileDate) {
        destDir.setLastModified(srcDir.lastModified());
      }
    }
docs: Internal copy directory method.
  
  @param srcDir  the validated source directory, must not be <code>null</code>
  @param destDir  the validated destination directory, must not be <code>null</code>
  @param filter  the filter to apply, null means copy all directories and files
  @param preserveFileDate  whether to preserve the file date
  @param exclusionList  List of files and directories to exclude from the copy, may be null
  @throws IOException if an error occurs
  @since 1.1