public static String toHTMLString(String in)
{
StringBuffer out = new StringBuffer();
for(int i = 0; in != null && i < in.length(); i++)
{
char c = in.charAt(i);
if (c == '\'')
out.append("'");
else if (c == '\"')
out.append(""");
else if (c == '<')
out.append("<");
else if (c == '>')
out.append(">");
else if (c == '&')
out.append("&");
else if (c == ' ')
out.append(" ");
else if (c == '\n')
out.append("
");
else
out.append(c);
}
return out.toString();
}
阅读(2613) | 评论(0) | 转发(0) |