public static void forceDelete(final File file) throws IOException {

        if (!file.exists()) {
            return;
        }

        if (file.isDirectory()) {
            deleteDirectory(file);
        } else {
            final boolean filePresent = file.exists();
            if (!file.delete()) {
                if (!filePresent) {
                    throw new FileNotFoundException("File does not exist: " + file);
                }
                final String message =
                        "Unable to delete file: " + file;
                throw new IOException(message);
            }
        }
    }
Deletes a file. If file is a directory, delete it and all sub-directories.
<p>
The difference between File.delete() and this method are:
<ul>
<li>A directory to be deleted does not have to be empty.</li>
<li>You get exceptions when a file or directory cannot be deleted.
(java.io.File methods returns a boolean)</li>
</ul>

@param file file or directory to delete, must not be {@code null}
@throws NullPointerException  if the directory is {@code null}
@throws FileNotFoundException if the file was not found
@throws IOException           in case deletion is unsuccessful
replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/utils/FileUtils.java