Here you can find the source of htmlEscape(final String text)
Parameter | Description |
---|---|
text | the text to be escaped. |
static String htmlEscape(final String text)
//package com.java2s; public class Main { /**/*w w w .j a v a 2s. c o m*/ * Escapes the text into proper HTML, converting characters into character entities when required. * @param text the text to be escaped. * @return the escaped text. */ static String htmlEscape(final String text) { return text.replaceAll("&", "&") // replace the ampersand first because it will show up later as part of character entities .replaceAll("<", "<").replaceAll(">", ">"); } }