import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class HtmlUtil {
* @Title: getText
* @Description: 解析html标签
* @param @param html串
* @return 文本内容
*/
public static String getText(String html) {
Document doc = Jsoup.parse(html);
String txtcontent = doc.text();
StringBuilder builder = new StringBuilder(txtcontent);
int index = 0;
while (builder.length() > index) {
char tmp = builder.charAt(index);
if (Character.isSpaceChar(tmp) || Character.isWhitespace(tmp)) {
builder.setCharAt(index, ' ');
}
index++;
}
txtcontent = builder.toString().replaceAll(" +", " ").trim();
return txtcontent;
}
}