Here you can find the source of unquoteHtmlContent(String x)
static public String unquoteHtmlContent(String x)
//package com.java2s; public class Main { private static final char[] htmlIn = { '&', '"', '\'', '<', '>', '\n' }; private static final String[] htmlOut = { "&", """, "'", "<", ">", "\n<p>" }; static public String unquoteHtmlContent(String x) { return unreplace(x, htmlOut, htmlIn); }//from w w w .ja va 2s .c o m /** * Replace all occurences of orgReplace with orgChar; inverse of replace(). * * @param x operate on this string * @param orgReplace get rid of these * @param orgChar replace with these * @return resulting string */ static public String unreplace(String x, String[] orgReplace, char[] orgChar) { // common case no replacement boolean ok = true; for (String anOrgReplace : orgReplace) { int pos = x.indexOf(anOrgReplace); ok = (pos < 0); if (!ok) break; } if (ok) return x; // gotta do it StringBuilder result = new StringBuilder(x); for (int i = 0; i < orgReplace.length; i++) { int pos = result.indexOf(orgReplace[i]); if (pos >= 0) { unreplace(result, orgReplace[i], orgChar[i]); } } return result.toString(); } /** * Replace any String "out" in sb with char "in". * * @param sb StringBuilder to replace * @param out repalce this String * @param in with this char */ static public void unreplace(StringBuilder sb, String out, char in) { int pos; while (0 <= (pos = sb.indexOf(out))) { sb.setCharAt(pos, in); sb.delete(pos + 1, pos + out.length()); } } }