Java File Path Delete deleteRecursive(File path)

Here you can find the source of deleteRecursive(File path)

Description

Delete a directory and its contents recursively

License

Open Source License

Parameter

Parameter Description
path The file path to include

Declaration

public static void deleteRecursive(File path) 

Method Source Code


//package com.java2s;
import java.io.*;

public class Main {
    /**//  w w  w . j  a v a2  s  .co m
     * Delete a directory and its contents recursively
     *
     * @param path The file path to include
     */
    public static void deleteRecursive(File path) {
        File[] c = path.listFiles();
        for (File file : c) {
            if (file.isDirectory()) {
                deleteRecursive(file);
                file.delete();
            } else {
                file.delete();
            }
        }

        path.delete();
    }
}

Related

  1. deleteRecursive(File path)
  2. deleteRecursive(File path)
  3. deleteRecursive(File path)
  4. deleteRecursive(File path)
  5. deleteRecursive(File path)
  6. deleteRecursive(File path, boolean debug)
  7. deleteRecursively(File path)
  8. deleteRecursively(File path, File parentCanonical)
  9. deleteSelectedFilesFromDirectory(final String directoryPath, final List filesList)