Java Utililty Methods File Delete

List of utility methods to do File Delete

Description

The list of methods to do File Delete are organized into topic(s).

Method

booleandelete(File file)
Recursively delete starting at the given file.
if (file.getParent() == null) {
    return false;
return deleteUsingJavaIO(file);
booleandelete(File file)
Recursively deletes the given File file .
if (file.isDirectory()) {
    File[] files = file.listFiles();
    if (files != null) {
        for (File f : files) {
            delete(f);
return file.delete();
booleandelete(File file)
Delete a file or directory and insure that the file is no longer present on file system.
if (file.isDirectory()) {
    flushDirectoryContent(file);
file.delete();
if (isFileDeleted(file)) {
    return true;
return waitUntilFileDeleted(file);
...
booleandelete(File file)
delete
if (file == null)
    return false;
return file.delete();
voiddelete(File file)
Delete a file or directory.
if (file.isDirectory()) {
    deleteDir(file);
} else {
    deleteFile(file);
booleandelete(File file)
delete
return file.exists() && file.delete();
booleandelete(File file)
delete
boolean deleteStatus = false;
if (file.isDirectory()) {
    deleteStatus = deleteDir(file);
} else {
    deleteStatus = file.delete();
return deleteStatus;
booleandelete(File file)
delete
if (!file.exists()) {
    return true;
if (file.isFile()) {
    return file.delete();
} else if (file.isDirectory()) {
    return deleteDir(file);
return false;
booleandelete(File file)
Deletes the file.
if (!file.exists())
    return false;
if (!file.delete())
    throw new IOException("cannot delete the file: " + file);
return true;
voiddelete(File file)
delete
if (file == null)
    throw new IllegalArgumentException("file");
if (file.isDirectory()) {
    for (File f : file.listFiles()) {
        if (f.getName().equals(".") || f.getName().equals(".."))
            continue;
        delete(f);
if (!file.delete())
    throw new RuntimeException("failed to delete file: " + file);