package com.qmth.paper.library;

import java.io.File;

public class FileTest {
    public static void main(String[] args) {
//        File file = new File("/Users/xiaofei/qmth/temporary/paperlibrary/file-temp/image/test-school-1");
        File file = new File("/Users/xiaofei/qmth/temporary/paperlibrary/file-temp/image/test-school-1");
        deleteFile(file.getPath());
    }

    public static boolean deleteFile(String dirName) {
        File file = new File(dirName);
        if (file.exists()) {
            if (file.isFile()) {
//                file.delete();
            } else {
                for (File listFile : file.listFiles()) {
                    deleteFile(listFile.getPath());
                }
                if(file.isDirectory() && file.listFiles().length == 0){
                    file.delete();
                }
            }
        }
        return true;
    }
}