java 去除字符串中的html代码

  /**
     * 移除字符串中包含HTML的标签
     * 
     * @param content
     * @return
     */
    public static String removeHTML(String content) {
        int before = content.indexOf('<');
        int behind = content.indexOf('>');
        if (before != -1 || behind != -1) {
            behind += 1;
            content = content.substring(0, before).trim()
                    + content.substring(behind, content.length()).trim();
            content = removeHTML(content);
        }
        return content;
    }

 

posted @ 2012-12-13 11:17  Caliven  阅读(260)  评论(0编辑  收藏  举报