Extract text from RTF In Java

Extract text from RTF with a few lines of Java code.


Download Free Trial

How to extract a text from RTF files Java API?

GroupDocs.Parser for Java is a text, image and metadata extractor API, supporting more than 50 popular document types to help building business applications with features of parsing raw, structured & formatted text. It also supports parsing documents using predefined templates and allows extracting complex data from invoices and other typical documents with speed and accuracy. GroupDocs.Parser for Java enables you to extract text and metadata from password protected files of all popular formats including Word processing documents, Excel spreadsheets, PowerPoint presentations, OneNote, PDF files and ZIP archives.

GroupDocs.Parser API is a right choice for corporate solutions which needs file text extraction feature. These APIs are well supported on all major operating systems and platforms including Java runtime: J2SE 6.0 and above.

Extract text from RTF in Java

GroupDocs.Parser for Java makes it easy for Java developers to extract a text from a RTF file by implementing a few easy steps.

  • Instantiate Parser object for the initial document;
  • Call getText method and obtain TextReader object;
  • Check if reader isn’t null (text extraction is supported for the document);
  • Read a text from reader.

How to extract text from RTF file using Java example code

// Extract text from RTF file using GroupDocs.Parser API
// Create an instance of Parser class
try (Parser parser = new Parser(filePath)) {
    // Extract a text into the reader
    try (TextReader reader = parser.getText()) {
        // Print a text from the document
        // If text extraction isn't supported, a reader is null
        System.out.println(reader == null ? "Text extraction isn't supported" : reader.readToEnd());
    }
}

System Requirements

GroupDocs.Parser for Java APIs are supported on all major platforms and operating systems. Before executing the code below, please make sure that you have the following prerequisites installed on your system.

  • Operating Systems: Microsoft Windows, Linux, MacOS
  • Development Environments: NetBeans, Intellij IDEA, Eclipse, etc.
  • Frameworks
  • Download the latest version of GroupDocs.Parser for Java from Maven

Why Use GroupDocs.Parser for Java

  • Plain text extraction support from any supported documents
  • Documents parsing via user-defined templates
  • Fully support structured text extraction
  • Text searching via keyword as well as regular expression
  • Extract formatted text, metadata, images, containers, and attachments
  • Extract table of contents for some supported document formats
  • Parse form data from PDF documents
  • Extract hyperlinks from the document

Live Demos - Extract text from RTF Online

Extract text from RTF file right now by visiting GroupDocs.Parser Live Demos website. The live demo has the following benefits.

No need to download API

No need to write any code

Just upload the source file

Get download link to save the file

Extract Text From Other Document Formats

Java documents parse & text extraction API for file formats and images. Extract data for some of the popular file formats as stated below.

VSDM

(Visio Macro-Enabled Drawing)

VSDX

(Visio Drawing)

VSSM

(Visio Macro-Enabled Stencil File)

VSSX

(Visio Stencil File)

VSTM

(Visio Macro-Enabled Drawing Template)

VSTX

(Visio Drawing Template)

VSX

(Visio Stencil XML File)

VTX

(Anim8or 3D Model)

XLAM

(Excel Macro-Enabled Add-In)

XLS

(Microsoft Excel Spreadsheet (Legacy))

XLSB

(Excel Binary Workbook)

XLSM

(Macro-enabled Spreadsheet)

XLSX

(Open XML Workbook)

XLT

(Excel 97 - 2003 Template)

XLTM

(Excel Macro-Enabled Template)

XLTX

(Excel Template)

Back to top
 English