Posted on 2008-06-04 17:19 
G_G 阅读(242) 
评论(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(
				
						"
						<
						"
						, 
						"
						<
						"
						).replaceAll(
						"
						>
						"
						, 
						"
						>
						"
				
				
						).
				
				
						replaceAll(
						"&", "&"
				
						)
				
				
						
						).append(
				"
				<br/>  
				"
				);
            }
				//
				while
            
				//
				如果是最后一行
				
						
				
				        } 
				catch
				 (IOException ex) {}
       
				return
				 
				"
				  
				"
				+
				ret.toString() ;
    }