public static boolean deleteDirectoryAndContents(File rootDirectory){
  if ((rootDirectory == null) || !rootDirectory.isDirectory()) {
    return false;
  }
  try {
    String[] directoryContents=rootDirectory.list();
    for (int i=0; i < directoryContents.length; i++) {
      boolean success=deleteDirectoryAndContents(new File(rootDirectory,directoryContents[i]));
      if (!success) {
        return false;
      }
    }
    return rootDirectory.delete();
  }
 catch (  Exception e) {
    logger.debug(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
    return false;
  }
}

public static boolean deleteDirectoryAndContents ( File rootDirectory ) { if ( ( rootDirectory == null ) || ! rootDirectory . isDirectory ( ) ) { return false ; } try { String [ ] directoryContents = rootDirectory . list ( ) ; for ( int i = 0 ; i < directoryContents . length ; i ++ ) { boolean success = deleteDirectoryAndContents ( new File ( rootDirectory , directoryContents [ i ] ) ) ; if ( ! success ) { return false ; } } return rootDirectory . delete ( ) ; } catch ( Exception e ) { logger . debug ( e . toString ( ) + System . lineSeparator ( ) + StackTrace . getStringFromStackTrace ( e ) ) ; return false ; } }
this is a quiet method . method template code from http : / / www . exampledepot . com / egs / java . io / deletedir . html
