Html富文本解析

截取掉标签,留下纯文本

pubtic class HtmlUtil extends HtmlEditorKit.ParserCallback {
StringBuffer sb =  new Stringbuffer();
public String panse(String str) throws IOException {
InputStreamvin = new ByteArrayInputStream(str.getBytes();
Reader reader = new InputStreamReader(in);
ParserDeLegator deLegetor = new ParserDelegatar();
deLegator.parse(reader, this, true);
in.close();

reader.close();
return sb.tostring();

}
@override
public void handLeText(char[] text, int pos) {
sb.append(text);
}
}

 


版权声明:本文为u011525878原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。