replace Html String entities - Android java.lang

Android examples for java.lang:String HTML

Description

replace Html String entities

Demo Code


//package com.java2s;

public class Main {

    public static String replaceHtmlString(String source) {

        if (source == null || source.length() <= 0)
            return source;

        source = source.replace("&#xd;", "");
        source = source.replace("&quot;", "\"");
        source = source.replace("&#039;", "'");
        source = source.replace("&apos;", "'");
        source = source.replace("&lt;", "<");
        source = source.replace("&gt;", ">");
        source = source.replace("&amp;", "&");
        source = source.replace("&ldquo;", "??");
        source = source.replace("&rdquo;", "??");
        source = source.replace("&nbsp;", " ");

        return source;
    }//from  ww w .  j  ava  2  s . c  om
}

Related Tutorials