Here you can find the source of htmlEntities(String text)
public static String htmlEntities(String text)
//package com.java2s; public class Main { /**// www.j a v a 2 s. c om * Converts the ampersand, quote, prime, less-than and greater-than * characters to their corresponding HTML entities in the given string. */ public static String htmlEntities(String text) { return text.replaceAll("&", "&").replaceAll("\"", """) .replaceAll("'", "′").replaceAll("<", "<") .replaceAll(">", ">"); } }