release branch 0.27.1

This commit is contained in:
houbb
2025-07-24 23:22:54 +08:00
parent c9069c8812
commit fca702af5b
8 changed files with 50 additions and 12 deletions

View File

@@ -1,9 +1,8 @@
package com.github.houbb.sensitive.word.support.allow;
import com.github.houbb.heaven.annotation.ThreadSafe;
import com.github.houbb.heaven.util.io.StreamUtil;
import com.github.houbb.sensitive.word.api.IWordAllow;
import com.github.houbb.sensitive.word.api.IWordDeny;
import com.github.houbb.sensitive.word.utils.InnerStreamUtils;
import java.util.List;
@@ -26,7 +25,7 @@ public class WordAllowSystem implements IWordAllow {
@Override
public List<String> allow() {
return StreamUtil.readAllLines("/sensitive_word_allow.txt");
return InnerStreamUtils.readAllLines("/sensitive_word_allow.txt");
}
}

View File

@@ -1,8 +1,8 @@
package com.github.houbb.sensitive.word.support.deny;
import com.github.houbb.heaven.annotation.ThreadSafe;
import com.github.houbb.heaven.util.io.StreamUtil;
import com.github.houbb.sensitive.word.api.IWordDeny;
import com.github.houbb.sensitive.word.utils.InnerStreamUtils;
import java.util.List;
@@ -25,9 +25,9 @@ public class WordDenySystem implements IWordDeny {
@Override
public List<String> deny() {
List<String> results = StreamUtil.readAllLines("/sensitive_word_dict.txt");
results.addAll(StreamUtil.readAllLines("/sensitive_word_dict_en.txt"));
results.addAll(StreamUtil.readAllLines("/sensitive_word_deny.txt"));
List<String> results = InnerStreamUtils.readAllLines("/sensitive_word_dict.txt");
results.addAll(InnerStreamUtils.readAllLines("/sensitive_word_dict_en.txt"));
results.addAll(InnerStreamUtils.readAllLines("/sensitive_word_deny.txt"));
return results;
}

View File

@@ -1,7 +1,7 @@
package com.github.houbb.sensitive.word.support.tag;
import com.github.houbb.heaven.util.io.StreamUtil;
import com.github.houbb.sensitive.word.api.IWordTag;
import com.github.houbb.sensitive.word.utils.InnerStreamUtils;
import java.util.List;
import java.util.Set;
@@ -16,7 +16,7 @@ public class WordTagSystem extends AbstractWordTag {
private final IWordTag wordTag;
public WordTagSystem() {
List<String> lines = StreamUtil.readAllLines("/sensitive_word_tags.txt");
List<String> lines = InnerStreamUtils.readAllLines("/sensitive_word_tags.txt");
this.wordTag = WordTags.lines(lines);
}

View File

@@ -0,0 +1,33 @@
package com.github.houbb.sensitive.word.utils;
import com.github.houbb.heaven.util.io.StreamUtil;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
/**
* @since 0.27.1
*/
public class InnerStreamUtils {
/**
* 获取文件,兼容为空的场景
* @param path 路径
* @return 结果
*/
public static List<String> readAllLines(String path) {
try(InputStream inputStream = StreamUtil.class.getResourceAsStream(path);) {
if(inputStream == null) {
return Collections.emptyList();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return StreamUtil.readAllLines(path);
}
}