Java get plain Text from RTF

javartf

I have on my database a column that holds text in RTF format.
How can I get only the plain text of it, using Java?

Best Answer

RTFEditorKit rtfParser = new RTFEditorKit();
Document document = rtfParser.createDefaultDocument();
rtfParser.read(new ByteArrayInputStream(rtfBytes), document, 0);
String text = document.getText(0, document.getLength());

this should work