Java Delete Directory deleteDirectory(final File directory)

Here you can find the source of deleteDirectory(final File directory)

Description

delete Directory

License

Open Source License

Declaration

public static boolean deleteDirectory(final File directory) 

Method Source Code

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

import java.io.File;

public class Main {
    public static boolean deleteDirectory(final File directory) {
        if (directory == null) {
            return false;
        }/*  w w w  .  j  av  a2s .co m*/
        final File[] files = directory.listFiles();
        for (int num = files.length, i = 0; i < num; ++i) {
            if (files[i].isDirectory()) {
                if (!deleteDirectory(files[i])) {
                    return false;
                }
            } else if (!files[i].delete()) {
                return false;
            }
        }
        return directory.delete();
    }
}

Related

  1. deleteDirectory(File sourceDirectory, FilenameFilter filter, boolean recursive, boolean deleteItself)
  2. deleteDirectory(final File dir)
  3. deleteDirectory(final File dir)
  4. deleteDirectory(final File dir)
  5. deleteDirectory(final File directory)
  6. deleteDirectory(final File directory)
  7. deleteDirectory(final String dir)
  8. deleteDirectory(final String targetDir)
  9. deleteDirectory(IProgressMonitor monitor, File directory)