private static boolean copyDir ( File pFrom , File pTo , boolean pOverWrite ) throws IOException { if ( pTo . exists ( ) && ! pTo . isDirectory ( ) ) { throw new IOException ( "A directory may only be copied to another directory, not to a file" ) ; } pTo . mkdirs ( ) ; // mkdir? boolean allOkay = true ; File [ ] files = pFrom . listFiles ( ) ; for ( File file : files ) { if ( ! copy ( file , new File ( pTo , file . getName ( ) ) , pOverWrite ) ) { allOkay = false ; } } return allOkay ; }
Copies a directory recursively . If the destination folder does not exist it is created