手记

输出空目录(无法用length长度为0判断)

    public static void empty(String path) {
        File file = new File(path);
        File[] files = file.listFiles();
        for (int i = files.length - 1; i >= 0; --i) {
            if (files[i].isDirectory()) {
                empty(files[i].getAbsolutePath());
                if (files[i].listFiles().length == 0) {
                    System.out.println(files[i].getAbsolutePath());
                }
            }
        }
    }
0人推荐
随时随地看视频
慕课网APP