import lombok.extern.slf4j.Slf4j; import org.junit.Test; import java.io.*; /** * @author reghao * @date 2022-06-20 14:31:14 */ @Slf4j public class FileTest { @Test public void test() throws IOException { String dirPath = "/opt/file/disk0/spider/bili/img/vidcover"; File dir = new File(dirPath); for (File file : dir.listFiles()) { if (file.isDirectory()) { continue; } long len = file.length(); if (len > 1024*1024) { log.error("{} 大小超过 1MiB", file.getAbsolutePath()); } } } }