Java Delete Directory deleteDirectory(File directory, boolean ignoreErrors)

Here you can find the source of deleteDirectory(File directory, boolean ignoreErrors)

Description

delete Directory

License

Open Source License

Declaration

public static boolean deleteDirectory(File directory, boolean ignoreErrors) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static boolean deleteDirectory(File directory, boolean ignoreErrors) {
        try {//from  ww w. ja v  a  2s.c o m
            if (directory.exists() && directory.isDirectory()) {
                File files[] = directory.listFiles();
                for (File file : files) {
                    if (file.isDirectory()) {
                        deleteDirectory(file, true);
                    } else {
                        file.delete();
                    }
                }
            }
        } catch (Exception ex) {
            if (!ignoreErrors)
                ex.printStackTrace();
        }
        return (directory.delete());
    }
}

Related

  1. deleteDirectory(File directory)
  2. deleteDirectory(File directory)
  3. deleteDirectory(File directory)
  4. deleteDirectory(File directory)
  5. deleteDirectory(File directory)
  6. deleteDirectory(File f)
  7. deleteDirectory(File f)
  8. deleteDirectory(File f)
  9. deleteDirectory(File f)