diff --git a/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java b/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java index 676c631cda437746056a46571e63683cbcbff0d7..939fbca0c4712524cf3a8cf14e801d05d89255d5 100644 --- a/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java +++ b/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java @@ -21,7 +21,7 @@ import java.util.List; */ public class FileContainsUtil { /** - * 默认不存在 + * 默认图片不存在 */ private static boolean IS_EXIST = false; /** @@ -37,9 +37,9 @@ public class FileContainsUtil { */ private static final String BLOG_FOLDER2 = "/Users/qinyingjie/Documents/idea-workspace/study/blog/"; /** - * 白名单 + * 图片白名单 */ - private static final List WHITELISTS = Arrays.asList( + private static final List PIC_PATH_WHITELISTS = Arrays.asList( "http://qinyingjie.top/blogImg/image-20230324112725149.png" , "http://qinyingjie.top/blogImg/logo.png" , "http://qinyingjie.top/blogImg/image-20230601124308164.png" @@ -54,10 +54,14 @@ public class FileContainsUtil { final List picNames = getPicName(PIC_PATH); System.out.println("图片总数为" + picNames.size()); if (CollectionUtil.isNotEmpty(picNames)) { - for (String picName : picNames) { + outerloop: + for (int i = 0; i < picNames.size(); i++) { + String picName = picNames.get(i); //是白名单里面的图片,直接忽略 - if (WHITELISTS.contains(picName)) { - continue; + for (String picPathWhitelist : PIC_PATH_WHITELISTS) { + if (picPathWhitelist.contains(picName)) { + continue outerloop; + } } //默认不存在 IS_EXIST = false;