public static void copyDirectory ( File src , File target ) { checkNotNull ( src , "src can't be null" ) ; checkNotNull ( target , "target can't be null" ) ; File [ ] files = src . listFiles ( ) ; if ( files == null ) { return ; } for ( File srcFile : files ) { if ( srcFile . isDirectory ( ) ) { File targetChild = new File ( target , srcFile . getName ( ) ) ; ensureExistingDirectory ( targetChild ) ; copyDirectory ( srcFile , targetChild ) ; } else { copyFileToDirectory ( srcFile , target ) ; } } }
Copies a directory recursively .