Here you can find the source of deleteFileOrDir(File fd)
fd
from the file system.
public static void deleteFileOrDir(File fd)
//package com.java2s; import java.io.File; public class Main { /**/*from w ww . ja va 2 s.com*/ * Deletes the directory or file <code>fd</code> from the file * system. Throws a {@link IllegalStateException} if the specified file * system entity cannot be deleted (e.g., because there is an open * file handle to that entity, or because the entity is a non-empty * directory). */ public static void deleteFileOrDir(File fd) { boolean deleted = fd.delete(); if (!deleted) { String type = fd.isFile() ? "file" : "directory"; throw new IllegalStateException("Unable to delete " + type + " '" + fd.getPath() + "'"); } } }