Here you can find the source of replaceHtmlEntitiesWithEmptyString(String stb)
public static String replaceHtmlEntitiesWithEmptyString(String stb)
//package com.java2s; /**/*from w w w .j a va 2 s.co m*/ * $Revision $ * $Date $ * * Copyright (C) 2005-2010 Jive Software. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Iterator; import java.util.Map; public class Main { private static Map HTML_ENTITY_MAP; public static String replaceHtmlEntitiesWithEmptyString(String stb) { Iterator i$ = HTML_ENTITY_MAP.keySet().iterator(); do { if (!i$.hasNext()) break; String key = (String) i$.next(); if (stb.contains(key)) stb = stb.replaceAll(key, ""); } while (true); i$ = HTML_ENTITY_MAP.values().iterator(); do { if (!i$.hasNext()) break; String value = (String) i$.next(); if (stb.contains(value)) stb = stb.replaceAll(value, ""); } while (true); return stb; } public static String replaceAll(String text, String token, String repl) { return replaceAll(new StringBuilder(text), token, repl).toString(); } public static StringBuilder replaceAll(StringBuilder text, String token, String repl) { int tokSize = token.length(); int i = 0; do { if (i == -1) break; i = text.indexOf(token, i); if (i != -1) { text.replace(i, i + tokSize, repl); i += repl.length(); } } while (true); return text; } public static String replace(String string, String oldString, String newString) { if (string == null) return null; if (newString == null) return string; int i = 0; if ((i = string.indexOf(oldString, i)) >= 0) { char string2[] = string.toCharArray(); char newString2[] = newString.toCharArray(); int oLength = oldString.length(); StringBuffer buf = new StringBuffer(string2.length); buf.append(string2, 0, i).append(newString2); i += oLength; int j; for (j = i; (i = string.indexOf(oldString, i)) > 0; j = i) { buf.append(string2, j, i - j).append(newString2); i += oLength; } buf.append(string2, j, string2.length - j); return buf.toString(); } else { return string; } } public static String replace(String line, String oldString, String newString, int count[]) { if (line == null) return null; int i = 0; if ((i = line.indexOf(oldString, i)) >= 0) { int counter = 1; char line2[] = line.toCharArray(); char newString2[] = newString.toCharArray(); int oLength = oldString.length(); StringBuffer buf = new StringBuffer(line2.length); buf.append(line2, 0, i).append(newString2); i += oLength; int j; for (j = i; (i = line.indexOf(oldString, i)) > 0; j = i) { counter++; buf.append(line2, j, i - j).append(newString2); i += oLength; } buf.append(line2, j, line2.length - j); count[0] = counter; return buf.toString(); } else { return line; } } }