FileTest.java 627 B

123456789101112131415161718192021222324252627
  1. import lombok.extern.slf4j.Slf4j;
  2. import org.junit.Test;
  3. import java.io.*;
  4. /**
  5. * @author reghao
  6. * @date 2022-06-20 14:31:14
  7. */
  8. @Slf4j
  9. public class FileTest {
  10. @Test
  11. public void test() throws IOException {
  12. String dirPath = "/opt/file/disk0/spider/bili/img/vidcover";
  13. File dir = new File(dirPath);
  14. for (File file : dir.listFiles()) {
  15. if (file.isDirectory()) {
  16. continue;
  17. }
  18. long len = file.length();
  19. if (len > 1024*1024) {
  20. log.error("{} 大小超过 1MiB", file.getAbsolutePath());
  21. }
  22. }
  23. }
  24. }