Java HTML Unescape unescapeHTML(String comment)

Here you can find the source of unescapeHTML(String comment)

Description

unescape HTML

License

Open Source License

Declaration

public static String unescapeHTML(String comment) 

Method Source Code

//package com.java2s;
/*//w  ww  . ja va2 s .  c  o m
 * M2M ServiceFOTA ONM version 1.0
 *
 *  Copyright ? 2014 kt corp. All rights reserved.
 *
 *  This is a proprietary software of kt corp, and you may not use this file except in
 *  compliance with license agreement with kt corp. Any redistribution or use of this
 *  software, with or without modification shall be strictly prohibited without prior written
 *  approval of kt corp, and the copyright notice above does not evidence any actual or
 *  intended publication of such software.
 */

public class Main {

    public static String unescapeHTML(String comment) {
        int length = comment.length();
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < length; ++i) {
            String comp = comment.substring(i, i + 1);
            if (" ".compareTo(comp) == 0) {
                comp = comment.substring(++i, i + 1);
                buffer.append("&nbsp");
            } else if ("\r".compareTo(comp) == 0) {
                comp = comment.substring(++i, i + 1);
                if ("\n".compareTo(comp) == 0)
                    buffer.append("<BR>\r");
                else
                    buffer.append("\r");
            } else if (",".compareTo(comp) == 0) {
                comp = comment.substring(++i, i + 1);
                buffer.append(" ");
            } else if ("\n".compareTo(comp) == 0) {
                buffer.append("<BR>\r");
            }
            buffer.append(comp);
        }
        return buffer.toString();
    }
}

Related

  1. htmlUnescape(String s)
  2. htmlUnescape(String source)
  3. unEscapeHTML(final String escapedHTML)
  4. unescapeHtml(final String input)
  5. unescapeHTML(String html)
  6. unescapeHtml(String s)
  7. unescapeHtml(String s)
  8. unescapeHTML(String s)