RTF libraries for Java
- RTFEditorKit (
javax.swing.text.rtf) is part of the JDK. It reads RTF into a SwingStyledDocumentand writes one back as RTF, which gives you text plus basic character and paragraph attributes. It ignores tables, pictures and many control words, and handles Unicode escapes poorly in older JDKs. Good for simple files and quick text extraction with no dependency. - RTF Parser Kit is a dedicated parser: it sends events (groups, commands, text) to a listener and handles code pages and Unicode escapes correctly. It includes text converters. Pick it for reliable text extraction or when you want to process RTF commands yourself.
Apache Tika also extracts text and metadata from RTF (its RTFParser), if you already use Tika for other formats.
- RTF Parser Kit RTF Parser Kit is a Java library for parsing RTF with correct encoding and Unicode handling. How to extract text from an RTF file.
- RTFEditorKit RTFEditorKit is the JDK's built-in RTF reader and writer. How to extract text from an RTF file in Java, read formatting attributes.