Java tutorial
//package com.java2s; /* * Copyright (c) Mirth Corporation. All rights reserved. * http://www.mirthcorp.com * * The software in this package is published under the terms of the MPL * license a copy of which has been included with this distribution in * the LICENSE.txt file. */ import java.util.Hashtable; public class Main { private static final Hashtable<String, String> decoder = new Hashtable<String, String>(300); public static String decode(String entity) { if (entity.charAt(entity.length() - 1) == ';') // remove trailing // semicolon entity = entity.substring(0, entity.length() - 1); if (entity.charAt(1) == '#') { int start = 2; int radix = 10; if (entity.charAt(2) == 'X' || entity.charAt(2) == 'x') { start++; radix = 16; } Character c = new Character((char) Integer.parseInt(entity.substring(start), radix)); return c.toString(); } else { String s = decoder.get(entity); if (s != null) return s; else return ""; } } }