private static String htmlEntityDecode(String data) {

            // HTML entity decoding
            data = data.replaceAll("\\&amp;", "&");

            // Nothing to decode
            if (data.indexOf("&#") == -1) {
                return data;
            }

            // Decoding 16 base
            StringBuffer decoded = new StringBuffer();
            int fromIndex        = 0;
            int start            = 0;
            int end              = 0;

            while ((start = data.indexOf("&#x", fromIndex)) != -1) {
                fromIndex = start;
                for (int i = start; i < data.length(); i++) {
                    if (data.charAt(i) == ';') {
                        end = i;
                        break;
                    }
                }
                decoded.append(data.substring(0, start));
                decoded.append((char) Integer.parseInt(data.substring(start + 3, end), 16));
                decoded.append(data.substring(end + 1));
                data = decoded.toString();

                start = 0;
                end   = 0;
                decoded.delete(0, decoded.length());
            }

            // Decoding 10 base
            fromIndex        = 0;
            start            = 0;
            end              = 0;
            decoded.delete(0, decoded.length());
            while ((start = data.indexOf("&#", fromIndex)) != -1) {
                fromIndex = start;
                for (int i = start; i < data.length(); i++) {
                    if (data.charAt(i) == ';') {
                        end = i;
                        break;
                    }
                }
                decoded.append(data.substring(0, start));
                decoded.append((char) Integer.parseInt(data.substring(start + 2, end), 10));
                decoded.append(data.substring(end + 1));
                data = decoded.toString();

                start = 0;
                end   = 0;
                decoded.delete(0, decoded.length());
            }

            return data;
        }