Here you can find the source of htmlToStr(String htmlStr, int max_count)
public static String htmlToStr(String htmlStr, int max_count)
//package com.java2s; //License from project: Apache License public class Main { public static String htmlToStr(String htmlStr, int max_count) { String result = ""; boolean flag = true; if (htmlStr == null) { return null; }//from w w w . j a v a 2s . c o m char[] a = htmlStr.toCharArray(); int length = a.length; for (int i = 0; i < length; i++) { if (a[i] == '<') { flag = false; continue; } if (a[i] == '>') { flag = true; continue; } if (flag == true) { result += a[i]; } } if (result.toString().length() <= max_count * 1.1) return result.toString(); return result.toString().substring(0, max_count) + "..."; } }