question: private static void doCopyDirectory ( File srcDir , File destDir , FileFilter filter , boolean preserveFileDate , List < String > exclusionList ) throws IOException { File [ ] srcFiles = filter == null ? srcDir . listFiles ( ) : srcDir . listFiles ( filter ) ; if ( srcFiles == null ) { 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 ) ; } } } if ( preserveFileDate ) { destDir . setLastModified ( srcDir . lastModified ( ) ) ; } }
target:  Internal copy directory method.