Java Delete File Recursively deleteRecursive(final File file)

Here you can find the source of deleteRecursive(final File file)

Description

delete Recursive

License

Apache License

Declaration

public static boolean deleteRecursive(final File file) 

Method Source Code

//package com.java2s;
/*#######################################################
 *
 *   Maintained by Gregor Santner, 2017-
 *   https://gsantner.net///from   w w  w.j  a  v  a 2  s .  c o m
 *
 *   License: Apache 2.0
 *  https://github.com/gsantner/opoc/#licensing
 *  https://www.apache.org/licenses/LICENSE-2.0
 *
#########################################################*/

import java.io.File;

public class Main {
    public static boolean deleteRecursive(final File file) {
        boolean ok = true;
        if (file.exists()) {
            if (file.isDirectory()) {
                for (File child : file.listFiles())
                    ok &= deleteRecursive(child);
            }
            ok &= file.delete();
        }
        return ok;
    }
}

Related

  1. deleteRecursive(File toDelete)
  2. deleteRecursive(File toDelete)
  3. deleteRecursive(final File dir)
  4. deleteRecursive(final File file)
  5. deleteRecursive(final File file)
  6. deleteRecursive(final File file, final boolean collect)
  7. deleteRecursiveDir(File directory)
  8. deleteRecursiveDirectories(String mainDir)
  9. deleteRecursiveDirectory(String dirName)