PNG JPG BMP TIFF DOC
  Product Family

Search DOC Formats in Java

Native and high performance Microsoft Word DOC file search using Java APIs, without the use of any software like Microsoft or Adobe PDF.

How to Search DOC File Using Java

In order to search Microsoft Word DOC file, we’ll use

Aspose.Words for Java

API which is a feature-rich, powerful and easy to use Search API for Java platform. You can download its latest version directly from

Maven

and install it within your Maven-based project by adding the following configurations to the pom.xml.

Repository


<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>

Dependency

<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>version of aspose-words API</version>
<classifier>jdk17</classifier>
</dependency>

Steps to Search DOC Files in Java

Developers can easily integrate code with just few lines as listed.

  • Load DOC file by instantiating Document Class object.
  • Instantiate FindReplaceOptions.
  • Use Pattern.compile() method to define a regex pattern
  • Use getRange().replace method to find and replace
  • Save DOC file.

System Requirements

Before integrating the code, make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
  • Get latest version of Aspose.Words for Java directly from Maven .
 

Search DOC Files - Java

// Load DOC file
Document doc = new Document("sourceFile.doc");
// Find and replace similar pattern words in the file
FindReplaceOptions options = new FindReplaceOptions();
doc.getRange().replace(Pattern.compile("[B|S|M]ad"), "[replaced]", options);
// Save the DOC file
doc.save("output.doc");  
 
  • Java Words API can be used to load, view and convert Microsoft Word and OpenDocument Formats like DOC, DOCX, ODT to PDF, XPS, HTML and various other formats. You can also create new documents from scratch and save them in the supported formats. It is a standalone API that is suitable for server side and backend systems where high performance is required. It does not depend on any software like Microsoft or OpenOffice. ‎

    Online DOC Search Live Demos

    DOC  What is DOC  File Format

    Files with .doc extension represent documents generated by Microsoft Word or other word processing documents in binary file format. The extension was initially used for plain text documentation on several different operating systems. It can contain several different types of data such as images, formatted as well as plain text, graphs, charts, embedded objects, links, pages, page formatting, print settings and a lot others. The format was popular for all sorts of documentation due to the variety of options it offers to users for writing manuals, proposals, specifications, resumes, articles or any similar documents. The updated version of DOC is DOCX which is based on Office OpenXML whose specifications are openly available.

    Read More

    Other Supported Search Documents

    Using Java, one can also search other files including.

    DOCX (Office 2007+ Words Document)
    HTML (Hyper Text Markup Language)
    MHTML (Web Page Archive Format)
    ODT (OpenDocument Text File Format)
    OTT (OpenDocument Standard Format)
    RTF (Rich Text Format)
    TXT (Text Document)
    XHTML (XML Text Based Markup)