Compare two DOCX files in Java using our difference checker. With our high-fidelity Java API, you can find the difference between compared DOCX documents and export the results to a convenient file format.
Comparing documents is a rather difficult function to implement. But our Java solution is designed so that you can get the most accurate result.
To compare two DOCX documents, our powerful Java library compares content at both the character level and word level. If only a character has been changed, the word will be marked as the whole changed.
This way you can no longer look for differences in documents manually, but instead use our Java API to compare documents.
Sometimes you are not sure if a document has not been modified, and comparing two document versions manually can be tricky. Or vice versa, you know for sure that the document has been changed, but manually searching for updated places is too hard.
In all these situations and more, you can diff two DOCX files using our product API. To compare two documents, simply load them, call the comparison method, and get the result in a convenient file format. This allows you to find even small changes that would be invisible to the human eye.
To compare DOCX s and verify how our Java library works, simply load the files you want to diff and select the export file format. After comparing two files, the document containing the difference of this comparison will be automatically loaded.
An important point: the compared documents should not have any revisions before calling the comparison method. And it is necessary to accept all revisions, which we have already taken care of in our example:
import com.aspose.words.*; Document docA = new Document("Input1.docx"); Document docB = new Document("Input2.docx"); // There should be no revisions before comparison. docA.acceptAllRevisions(); docB.acceptAllRevisions(); docA.compare(docB, "Author Name", new Date()); docA.save("Output.docx");
Java SE 7 and more recent Java versions are supported. We also provide a separate package for Java SE 6 in case you are obliged to use this outdated JRE.
Our Java package is cross-platform and runs on all operating systems with JVM implementation, including Microsoft Windows, Linux, macOS, Android and iOS.
For information on optional package dependencies, such as JogAmp JOGL, Harfbuzz font engine, Java Advanced Imaging JAI, please refer to Product Documentation.