public void removeDirectoryRecursive(String dir) throws IOException {
  for (  File f : listFiles(dir)) {
    String name=f.getName();
    if (f.isDirectory()) {
      if (!name.equals(".") && !name.equals("..")) {
        removeDirectoryRecursive(dir + "/" + name);
      }
    }
 else {
      delete(dir + "/" + name);
    }
  }
  removeDirectory(dir);
}

public void removeDirectoryRecursive ( String dir ) throws IOException { for ( File f : listFiles ( dir ) ) { String name = f . getName ( ) ; if ( f . isDirectory ( ) ) { if ( ! name . equals ( "." ) && ! name . equals ( ".." ) ) { removeDirectoryRecursive ( dir + "/" + name ) ; } } else { delete ( dir + "/" + name ) ; } } removeDirectory ( dir ) ; }
remove all files and directory in a directory , and then delete the directory itself .
