????
public
?
static
?String?filter(String?input)?{
???????? if ?(input? == ? null )?{
???????????? return ? null ;
????????}
????????StringReader?stringReader? = ? new ?StringReader(input);
????????BufferedReader?reader? = ? new ?BufferedReader(stringReader);
????????StringBuffer?ret? = ? new ?StringBuffer(input.length()? + ? 200 ); // ?add?more?room?to?the?result?String
????????String?line? = ? null ;
???????? try ?{
??? ?? ?? ? //換行后添加<br/>
???????????? while ?((line? = ?reader.readLine())? != ? null )?{
??? ?? ?? ?? ?? //wap 對 <? >的替換
????????????????ret.append(line.replaceAll( " < " ,? " < " ).replaceAll( " > " ,? " > " ). replaceAll( "&",?"&" ) ).append( " <br/> " );
????????????} // while
???????????? // 如果是最后一行
????????}? catch ?(IOException?ex)?{}
??????? return ? " " + ret.toString()?;
????}
????
???????? if ?(input? == ? null )?{
???????????? return ? null ;
????????}
????????StringReader?stringReader? = ? new ?StringReader(input);
????????BufferedReader?reader? = ? new ?BufferedReader(stringReader);
????????StringBuffer?ret? = ? new ?StringBuffer(input.length()? + ? 200 ); // ?add?more?room?to?the?result?String
????????String?line? = ? null ;
???????? try ?{
??? ?? ?? ? //換行后添加<br/>
???????????? while ?((line? = ?reader.readLine())? != ? null )?{
??? ?? ?? ?? ?? //wap 對 <? >的替換
????????????????ret.append(line.replaceAll( " < " ,? " < " ).replaceAll( " > " ,? " > " ). replaceAll( "&",?"&" ) ).append( " <br/> " );
????????????} // while
???????????? // 如果是最后一行
????????}? catch ?(IOException?ex)?{}
??????? return ? " " + ret.toString()?;
????}
????