Java File Path Delete deleteDir(File path)

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

Description

delete Dir

License

Open Source License

Declaration

public static boolean deleteDir(File path) 

Method Source Code

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

import java.io.*;

public class Main {
    public static boolean deleteDir(File path) {
        if (path.exists()) {
            File[] files = path.listFiles();
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    deleteDir(files[i]);
                } else {
                    files[i].delete();//  w  w w  .j  a v a  2 s  .c o  m
                }
            }
        }
        boolean ok = path.delete();
        if (!ok)
            System.err.println("[WARN] Unable to delete: " + path);
        return ok;
    }
}

Related

  1. deleteDir(File fDir)
  2. deleteDir(File file)
  3. deleteDir(File path)
  4. deleteDir(File path)
  5. deleteDir(File path)
  6. deleteDir(final String path)
  7. deleteDir(String path)
  8. deleteDir(String path)
  9. deleteDirByDoc(String path)