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

voiddelete(File file)
delete
if (!file.exists()) {
    return;
if (file.isDirectory()) {
    String[] entries = file.list();
    if (entries.length == 0) {
        file.delete();
    } else {
...
booleandelete(File file)
Deletes a file.
logger.entering("de.axelwernicke.mypod.util.FileUtils", "delete");
boolean success = false;
try {
    if (file.canRead() && file.canWrite()) {
        boolean deleted = file.delete();
        if (!deleted) {
            file.deleteOnExit();
        success = true;
} catch (Exception e) {
    logger.warning("Exception raised: " + e.getMessage());
    e.printStackTrace();
logger.exiting("de.axelwernicke.mypod.util.FileUtils", "delete");
return success;
voiddelete(File file)
Recursively deletes file or directory.
if (file.exists()) {
    if (file.isDirectory()) {
        for (File c : file.listFiles()) {
            delete(c);
    if (!file.delete()) {
        throw new IOException("Could not delete " + file.getAbsolutePath());
...
Listdelete(File file)
Deletes a file or a directory and all of its contents
List<File> failures = new ArrayList<File>();
if (file.isDirectory()) {
    deleteContents(file, failures);
if (!file.delete()) {
    failures.add(file);
return failures;
...
voiddelete(File file)
delete
delete(file, false);
voiddelete(File file)
delete
if (file.isFile())
    file.delete();
else if (file.isDirectory()) {
    File[] files = file.listFiles();
    if (files != null && files.length > 0) {
        for (File f : files) {
            delete(f);
    file.delete();
voiddelete(File file)
Delete the given file or directory.
if (file.isDirectory()) {
    safelyDeleteContents(file);
file.delete();
voiddelete(File file)
delete
if (!file.exists())
    return;
if (file.delete())
    return;
System.gc();
if (file.delete())
    return;
try {
...
voiddoDelete(File f)
do Delete
try {
    if (f != null && f.exists()) {
        f.delete();
} catch (Exception e) {
booleandoDelete(File file)
do Delete
if (!file.isDirectory())
    return file.delete();
File[] files = file.listFiles();
if (files == null)
    return file.delete();
for (File child : files) {
    if (!doDelete(child))
        return false;
...