public static boolean deleteRecursive(File fileOrDirectory){
  if (fileOrDirectory.isDirectory()) {
    File[] list=fileOrDirectory.listFiles();
    if (list == null) {
      return false;
    }
    for (    File f : list) {
      if (!deleteRecursive(f)) {
        return false;
      }
    }
  }
  if (!fileOrDirectory.delete()) {
    if (fileOrDirectory.exists()) {
      return false;
    }
  }
  return true;
}

public static boolean deleteRecursive ( File fileOrDirectory ) { if ( fileOrDirectory . isDirectory ( ) ) { File [ ] list = fileOrDirectory . listFiles ( ) ; if ( list == null ) { return false ; } for ( File f : list ) { if ( ! deleteRecursive ( f ) ) { return false ; } } } if ( ! fileOrDirectory . delete ( ) ) { if ( fileOrDirectory . exists ( ) ) { return false ; } } return true ; }
remove specified file or directory .
