public static boolean deleteDir(File dir) {
        if (null == dir || !dir.exists())
            return false;
        if (!dir.isDirectory())
            throw new RuntimeException("\"" + dir.getAbsolutePath() + "\" should be a directory!");
        File[] files = dir.listFiles();
        boolean re = false;
        if (null != files) {
            if (files.length == 0)
                return dir.delete();
            for (File f : files) {
                if (f.isDirectory())
                    re |= deleteDir(f);
                else
                    re |= deleteFile(f);
            }
            re |= dir.delete();
        }
        return re;
    }
public static boolean deleteDir(File dir) {
        if (null == dir || !dir.exists())
            return false;
        if (!dir.isDirectory())
            throw new RuntimeException("\"" + dir.getAbsolutePath() + "\" should be a directory!");
        File[] files = dir.listFiles();
        boolean re = false;
        if (null != files) {
            if (files.length == 0)
                return dir.delete();
            for (File f : files) {
                if (f.isDirectory())
                    re |= deleteDir(f);
                else
                    re |= deleteFile(f);
            }
            re |= dir.delete();
        }
        return re;
    }
public static boolean deleteDir ( File dir ) { if ( null == dir || ! dir . exists ( ) ) return false ; if ( ! dir . isDirectory ( ) ) throw new RuntimeException ( "\"" + dir . getAbsolutePath ( ) + "\" should be a directory!" ) ; File [ ] files = dir . listFiles ( ) ; boolean re = false ; if ( null != files ) { if ( files . length == 0 ) return dir . delete ( ) ; for ( File f : files ) { if ( f . isDirectory ( ) ) re |= deleteDir ( f ) ; else re |= deleteFile ( f ) ; } re |= dir . delete ( ) ; } return re ; }
强行删除一个目录，包括这个目录下所有的子目录和文件

@param dir
目录
@return 是否删除成功
强行删除一个目录，包括这个目录下所有的子目录和文件