package org.guyezhai.utils;import java.text.CharacterIterator;import java.text.StringCharacterIterator;public class StringUtils { public static String htmlEncode(String aText){ final StringBuilder result = new StringBuilder(); final StringCharacterIterator iterator = new StringCharacterIterator(aText); char character = iterator.current(); while (character != CharacterIterator.DONE) { if (character == '<') { result.append("<"); } else if (character == '>') { result.append(">"); } else if (character == '&') { result.append("&"); } else if (character == '\"') { result.append("""); } else { result.append(character); } character = iterator.next(); } return result.toString(); }}