Infolinks In Text Ads

Jun 25, 2010

How to remove html tag from string?

public String removeHTMLTag(String html) {
        String finalString = "";
        try {
            finalString = html.replaceAll("\\<.*?>", "");

          
            finalString = finalString.replaceAll("\\&.*?;", "");
            finalString = finalString.replace("\r\n", " ");
            finalString = finalString.replace("\n", " ");
            finalString = finalString.replace("\t", " ");
            finalString = finalString.replaceAll("\\<.*?>", "");
            finalString = finalString.replaceAll("\\s+", " ");
            finalString = finalString.trim();
            // System.out.println(finalString);
            return finalString;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return html;
    }

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...