Here you can find the source of escapeHTML(String text)
public static String escapeHTML(String text)
//package com.java2s; /* Copyright Panopto 2009 - 2011 * // ww w . j a v a 2s . c om * This file is part of the Panopto plugin for Blackboard. * * The Panopto plugin for Blackboard is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The Panopto plugin for Blackboard is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the Panopto plugin for Blackboard. If not, see <http://www.gnu.org/licenses/>. */ import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class Main { public static String escapeHTML(String text) { StringBuilder escaped = new StringBuilder(); StringCharacterIterator iterator = new StringCharacterIterator(text); char character = iterator.current(); while (character != CharacterIterator.DONE) { if (character == '<') { escaped.append("<"); } else if (character == '>') { escaped.append(">"); } else if (character == '&') { escaped.append("&"); } else if (character == '\"') { escaped.append("""); } else if (character == '\'') { escaped.append("'"); } else if (character == '(') { escaped.append("("); } else if (character == ')') { escaped.append(")"); } else if (character == '#') { escaped.append("#"); } else if (character == '%') { escaped.append("%"); } else if (character == ';') { escaped.append(";"); } else if (character == '+') { escaped.append("+"); } else if (character == '-') { escaped.append("-"); } else { escaped.append(character); } character = iterator.next(); } return escaped.toString(); } }