【批量删除文件】Mac电脑批量删除.avi文件

package cn.sgy.delete;

import java.io.File;
import java.io.FilenameFilter;

public class FileExer {
    public static void main(String[] args) {
        File file = new File("/Users/songgenyao/Documents");
        getDocx(file);

    }

    private static void getDocx(File file) {
        if (file == null) {
            throw new NullPointerException("亲,不要传入空文件啊~~~");
        }
        if (file.isDirectory()) {
            File[] fs = file.listFiles();
            for (File f : fs) {
                getDocx(f);
            }
        } else if (file.getName().endsWith(".avi")) {
            if(file.exists()){  
                file.delete();  
            }

        }

    }

}

猜你喜欢

转载自www.cnblogs.com/songyao2018/p/9212921.html
今日推荐