Here you can find the source of filterHtmlAndTruncate(String s)
public static String filterHtmlAndTruncate(String s)
//package com.java2s; //License from project: Apache License public class Main { public static final int DEFAULT_MAX_CONTENT_LENGTH = 255; public static String filterHtmlAndTruncate(String s) { return filterHtmlAndTruncate(s, DEFAULT_MAX_CONTENT_LENGTH); }/*from ww w. j av a 2 s. c o m*/ public static String filterHtmlAndTruncate(String s, int maxLength) { String content = filterHtml(s); if (content == null) { return ""; } else { if (content.length() > maxLength) { return content.substring(0, maxLength - 3) + "..."; } else { return content; } } } public static String filterHtml(String s) { if (s == null) { return null; } s = s.replaceAll("<", ""); s = s.replaceAll(">", ""); s = s.replaceAll(" ", ""); s = s.replaceAll("(?s)<!--.*?-->", ""); return s.replaceAll("(?s)<.*?>", ""); } }