Java File Path Delete deleteDirectory(File path, boolean includeDir)

Here you can find the source of deleteDirectory(File path, boolean includeDir)

Description

delete Directory

License

Apache License

Declaration

static public boolean deleteDirectory(File path, boolean includeDir) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    static public boolean deleteDirectory(File path, boolean includeDir) {
        boolean success = true;
        if (path.exists()) {
            File[] files = path.listFiles();
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    success = deleteDirectory(files[i], true) && success;
                } else {
                    success = files[i].delete() && success;
                }//from w w  w  .j a v  a 2s.c  o m
            }
        }
        if (includeDir)
            success = path.delete() && success;
        return success;
    }
}

Related

  1. deleteDirectory(File path)
  2. deleteDirectory(File path)
  3. deleteDirectory(File path)
  4. deleteDirectory(File path)
  5. deleteDirectory(File path, boolean deleteMyself, boolean deleteHidden)
  6. deleteDirectory(final File path)
  7. deleteDirectory(final File path)
  8. deleteDirectory(final String directoryPath)
  9. deleteDirectory(final String fullDirPath)