解决方案 »
- 加急!单个Frame中显示多个jfreechart柱状图问题?
- 其实我知道我理解错了,各位给条明路。最好让我理解思路!谢谢!
- 请教
- 建一个文件,再建一个txt文件,打印十行字用线程实现.我写的程序太难看了.在线等,高手帮忙
- 编写JAVA程序实现从命令行获得字符串倒置后打印
- 如何在JAVA中实现将DBF转换成SQL SERSVER表
- 请教一个编码规范的问题
- Java里的SQL语句执行有问题
- 怎么判断用户离线?
- 请问大家,哪有中文的sl-275教材下载?
- Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException:
- 咨询一个实时提醒程序的思路
大概2600多行我现在大概弄成这样了 但是不知道返回值最后怎么传到servlet去public class KeywordFilterUtil{
private static KeywordFilterUtil instance; private static List<String> cont;
public static synchronized KeywordFilterUtil getIntance() {
if (instance == null) {
instance = new KeywordFilterUtil();
}
return instance;
} public static KeyWordResult KeyWordCheck(String key) {
return checkWord(key);
} private static KeyWordResult checkWord(String key) {
KeyWordResult kwr = new KeyWordResult();
kwr.setStatus("1");
kwr.setKeyword(key);
try {
if(cont==null){
//读取文件
File file = FileUtils.getFileForClassPath("flier.txt");
BufferedReader bReader = null;
FileInputStream inFile = null;
String line = null;
cont = new ArrayList<String>();
inFile = new FileInputStream(file);
bReader = new BufferedReader(new InputStreamReader(inFile, "GBK"));
while (true) {
line = bReader.readLine();
if (line == null) {
break;
}
cont.add(line);
}
}
//比对敏感词如果出现则替换为*号
for (String string : cont) {
if (key.contains(string)) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < string.length(); i++) {
sb.append("*");
}
key = key.replace(string, sb.toString());
kwr.setStatus("0");
kwr.setKeyword(key);
} else {
kwr.setKeyword(key);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return kwr;
}
}