Convert HTML to plain text in Java

前端 未结 6 2578
终归单人心
终归单人心 2021-02-20 08:51

I need to convert HTML to plain text. My only requirement of formatting is to retain new lines in the plain text. New lines should be displayed not only in the case of <

6条回答
  •  醉酒成梦
    2021-02-20 09:30

    I would guess you could use the ParserCallback.

    You would need to add code to support the tags that require special handling. There are:

    1. handleStartTag
    2. handleEndTag
    3. handleSimpleTag

    callbacks that should allow you to check for the tags you want to monitor and then append a newline character to your buffer.

提交回复
热议问题