Java File Path Delete deleteDir(File dirFile)

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

Description

delete Dir

License

Apache License

Declaration

public static boolean deleteDir(File dirFile) 

Method Source Code


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

import java.io.File;

public class Main {

    public static boolean deleteDir(File dirFile) {
        if (!dirFile.exists()) {
            return false;
        }//from  w ww .  j a  v a 2s. c  om

        if (dirFile.isFile()) {
            return dirFile.delete();
        } else {
            File[] files = dirFile.listFiles();
            if (files == null || files.length == 0) {
                return dirFile.delete();
            }
            for (File file : files) {
                deleteDir(file);
            }
        }

        return dirFile.delete();
    }
}

Related

  1. deleteDir(File directory)
  2. deleteDir(File directory)
  3. deleteDir(File directory)
  4. deleteDir(File directory)
  5. deleteDir(File directory, boolean removeAll)
  6. deleteDir(File dirPath)
  7. deleteDir(File f)
  8. deleteDir(File f)
  9. deleteDir(File f)