Java Utililty Methods Delete File if Exist

List of utility methods to do Delete File if Exist

Description

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

Method

voiddeleteIfExists(File f)
delete If Exists
assert !f.exists() || f.delete();
booleandeleteIfExists(File file)
delete If Exists
if (file == null) {
    return true;
return file.delete();
booleandeleteIfExists(File file)
Loescht die angegebene Datei falls sie existiert.
if (file.exists()) {
    return file.delete();
} else {
    return true;
voiddeleteIfExists(File file)
delete If Exists
boolean result = file.delete();
if (!result && file.exists()) {
    throw new IOException("Failed to delete " + file.getAbsolutePath());
booleandeleteIfExists(final File file)
Delete the specified file (or directory).
if ((file == null) || !file.exists()) {
    return false;
return file.delete();
booleandeleteIfExists(final File file)
delete If Exists
return file.exists() && !file.delete();
voiddeleteIfExists(java.io.File file)
delete If Exists
if (file.exists()) {
    boolean isSuccessful = file.delete();
    assert isSuccessful : file;
    assert file.exists() == false : file;