public static void dumbDeleteRecursive(File file) throws IOException {
    if (file.isDirectory()) {
      File[] fileList = file.listFiles();
      if (fileList == null) {
        // If file is not a directory, listFiles() will return null
        return;
      }
      for (File entry : fileList) {
        dumbDeleteRecursive(entry);
      }
    }

    if (!file.delete() && file.exists()) {
      throw new IOException("could not delete: " + file);
    }
  }
public static void dumbDeleteRecursive ( File file ) throws IOException { if ( file . isDirectory ( ) ) { File [ ] fileList = file . listFiles ( ) ; if ( fileList == null ) { return ; } for ( File entry : fileList ) { dumbDeleteRecursive ( entry ) ; } } if ( ! file . delete ( ) && file . exists ( ) ) { throw new IOException ( "could not delete: " + file ) ; } }
Delete a directory and its contents.

WARNING: Java APIs do not let us distinguish directories from symbolic links to directories.
Consequently, if the directory contains symbolic links to directories, we will attempt to
delete the contents of pointed-to directories.

@param file File or directory to delete