Here you can find the source of htmlEncode(String input)
Parameter | Description |
---|---|
input | the String to convert |
public static String htmlEncode(String input)
//package com.java2s; public class Main { /**/*from w w w . j a va 2 s .com*/ * HTML-encode a string. This simple method only replaces the five characters &, <, >, ", and '. * * @param input the String to convert * @return a new String with HTML encoded characters */ public static String htmlEncode(String input) { String output = input.replaceAll("&", "&"); output = output.replaceAll("<", "<"); output = output.replaceAll(">", ">"); output = output.replaceAll("\"", """); output = output.replaceAll("'", "'"); return output; } }