public static boolean deleteDir(File dir){
  if (dir == null) {
    return false;
  }
  if (dir.isDirectory()) {
    String[] children=dir.list();
    for (    String child : children) {
      boolean success=deleteDir(new File(dir,child));
      if (!success) {
        return false;
      }
    }
  }
  return dir.delete();
}

public static boolean deleteDir ( File dir ) { if ( dir == null ) { return false ; } if ( dir . isDirectory ( ) ) { String [ ] children = dir . list ( ) ; for ( String child : children ) { boolean success = deleteDir ( new File ( dir , child ) ) ; if ( ! success ) { return false ; } } } return dir . delete ( ) ; }
delete a selected directory recursively
