wap 文本展现 简单替换



     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(
" < " " &lt; " ).replaceAll( " > " " &gt; " ). replaceAll( "& " " &amp; " ) ).append( " <br/>&nbsp;&nbsp; " );
            }
// while
            
// 如果是最后一行
        }  catch  (IOException ex) {}

       
return   " &nbsp;&nbsp; " + ret.toString() ;

    }

    

你可能感兴趣的:(wap 文本展现 简单替换)