public class SensitiveWordsUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
filePath |
static int |
MATCH_TYPE_MAX |
static int |
MATCH_TYPE_MIN |
static Map<String,String> |
wordMap |
static Set<String> |
words |
| 构造器和说明 |
|---|
SensitiveWordsUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
checkSensitiveWords(String txt,
int beginIndex,
int matchType)
Description:检查文字中是否包含敏感字符,检查规则如下:
|
static boolean |
containsSensitiveWords(String txt,
int matchType)
Description:判断文字是否包含敏感字符
|
static Set<String> |
getSensitiveWords(String txt,
int matchType)
Description:获取文字中的敏感词
|
static Set<String> |
readTxtByLine(String filePath) |
static String |
replaceSensitiveWords(String txt,
int matchType,
String replaceChar)
Description: 替换敏感字字符
|
public static String filePath
public static int MATCH_TYPE_MIN
public static int MATCH_TYPE_MAX
public static int checkSensitiveWords(String txt, int beginIndex, int matchType)
txt - beginIndex - matchType - public static boolean containsSensitiveWords(String txt, int matchType)
txt - 文字matchType - 匹配规则 1:最小匹配规则,2:最大匹配规则public static String replaceSensitiveWords(String txt, int matchType, String replaceChar)
txt - matchType - replaceChar - 替换字符,默认*Copyright © 2020. All Rights Reserved.