posts - 149, comments - 165, trackbacks - 0, articles - 1
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

wap 文本展现 简单替换

Posted on 2008-06-04 17:19 G_G 阅读(51) 评论(0)  编辑  收藏 所属分类: javaGeneral


     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() ;

    }

    


标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-06-10 13:32 编辑过
 
 
相关链接:
网站导航: