Java Delete Directory deleteDirectory(File f)

Here you can find the source of deleteDirectory(File f)

Description

delete Directory

License

Open Source License

Declaration

public static boolean deleteDirectory(File f) throws IOException 

Method Source Code


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

import java.io.File;
import java.io.IOException;

public class Main {
    public static boolean deleteDirectory(File f) throws IOException {
        if (f.exists() && f.isDirectory()) {
            File[] files = f.listFiles();
            if (null != files) {
                for (int i = 0; i < files.length; i++) {
                    if (files[i].isDirectory()) {
                        deleteDirectory(files[i]);
                    } else {
                        files[i].delete();
                    }/*from   ww  w  .  j a v a 2  s .c  o m*/
                }
            }
        } else if (f.exists() && f.isFile()) {
            return f.delete();
        }
        return (f.delete());
    }
}

Related

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