import java.util.*;
public class StringTest{
public static void main(String[] args){
String s="敏感 <avbd> 我额度";
HtmlFileter hf=new HtmlFileter();
StringFileter sf=new StringFileter();
FileterList fl=new FileterList();
fl.add(hf).add(sf);
fl.doFileter(s);
String ss=hf.doFileter(s);
System.out.println(s);
System.out.println(ss);
}
}
interface Fileter{
String doFileter(String s);
}
class HtmlFileter implements Fileter{
public String doFileter(String s){
s.replace('<','[');
s.replace('>',']');
return s;
}
}
class StringFileter implements Fileter{
public String doFileter(String s){
//s.replace("敏感","");
return s;
}
}
class FileterList implements Fileter{
private ArrayList al=new ArrayList();
public FileterList add(Fileter f){
al.add(f);
return this;
}
public String doFileter(String s){
Iterator i=al.iterator();
if(i.hasNext()){
((Fileter)(i.next())).doFileter(s);
return s;
}
else{
return s;
}
}
}
为什么我的repalece 没用?