public static boolean deleteDir(File dir){
  if (dir.isDirectory()) {
    String[] children=dir.list();
    for (int i=0; i < children.length; i++) {
      boolean success=deleteDir(new File(dir,children[i]));
      if (!success) {
        LOG.error("Error trying to delete file: " + dir.getAbsolutePath());
      }
    }
  }
  return dir.delete();
}

public static boolean deleteDir ( File dir ) { if ( dir . isDirectory ( ) ) { String [ ] children = dir . list ( ) ; for ( int i = 0 ; i < children . length ; i ++ ) { boolean success = deleteDir ( new File ( dir , children [ i ] ) ) ; if ( ! success ) { LOG . error ( "Error trying to delete file: " + dir . getAbsolutePath ( ) ) ; } } } return dir . delete ( ) ; }
deletes all files and subdirectories under " dir " .
