public class DirtyFilter {
private int rs = -1;
public String[] dirtyArr = {};//脏字数组
public boolean containDirty(String str){
if(str !=null && str != ""){
System.out.println(str);
Arrays.sort(dirtyArr);
int len = str.length();
for(int i=0;i<len;i++){
for(int j=len;j>i;j--){
rs = Arrays.binarySearch(dirtyArr, str.substring(i, j));
if(rs>=0){
return true;
}
}
}
}
return false;
}
转载于:https://my.oschina.net/dlxc520/blog/15621