当前位置: 技术问答>java相关
怎么样过滤html代码
来源: 互联网 发布时间:2015-09-28
本文导语: 怎么样过滤html代码 | 我写了一个类: package com.toone.util; import java.io.*; import java.util.*; public class HtmlConverter { public static String convert(String pContent) { ...
怎么样过滤html代码
|
我写了一个类:
package com.toone.util;
import java.io.*;
import java.util.*;
public class HtmlConverter
{
public static String convert(String pContent)
{
StringBuffer buffer=new StringBuffer();
StringTokenizer token=new StringTokenizer(pContent,"rn");
while(token.hasMoreTokens())
{
String temp=token.nextToken();
buffer.append("
"+convert2(temp));
}
return buffer.toString();
}
public static String convert2( String input ) {
if( input == null || input.length() == 0 ) {
return input;
}
StringBuffer buf = new StringBuffer(input.length()+6);
char ch = ' ';
for( int i=0; i
package com.toone.util;
import java.io.*;
import java.util.*;
public class HtmlConverter
{
public static String convert(String pContent)
{
StringBuffer buffer=new StringBuffer();
StringTokenizer token=new StringTokenizer(pContent,"rn");
while(token.hasMoreTokens())
{
String temp=token.nextToken();
buffer.append("
"+convert2(temp));
}
return buffer.toString();
}
public static String convert2( String input ) {
if( input == null || input.length() == 0 ) {
return input;
}
StringBuffer buf = new StringBuffer(input.length()+6);
char ch = ' ';
for( int i=0; i