Our powerful Java SDK allows you to find the difference between HTML documents and save the results to a convenient format for viewing. To verify our product capabilities, compare HTML files using this Java library and see the differences.
Our Java SDK is designed to give you the most accurate result, even though comparison is a complex function itself.
Sometimes you need to be sure that the document in the HTML format has not been changed, and if it has, you need to find out what the difference is. Just use our Java diff tool to compare two HTML files and find differences in whole words or single characters. Moreover, if only one character in a word has changed, this word will be marked as changed entirely.
Now you no longer need to spend time manually comparing HTML documents, and you can quickly find even small changes and export such diffs to a document in a convenient format.
Check out how our solution to compare HTML files using Java SDK works. To achieve this, load the HTML files you want to compare and select the export file format – it will be automatically loaded after comparing.
Note that you need to accept all revisions in compared documents before calling the comparison method, as shown in our example:
import com.aspose.words.cloud.*;
ApiClient apiClient = new ApiClient("####-####-####-####-####", "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);
String fileName1 = "Input1.html";
String fileName2 = "Input2.html";
String fileResult = "Output.html";
// Upload documents to cloud storage.
byte[] firstDocumentContent = Files.readAllBytes(Paths.get(fileName1).toAbsolutePath());
UploadFileRequest uploadFirstFileRequest =
new UploadFileRequest(firstDocumentContent, fileName1, null);
wordsApi.uploadFile(uploadFirstFileRequest);
byte[] secondDocumentContent = Files.readAllBytes(Paths.get(fileName2).toAbsolutePath());
UploadFileRequest uploadSecondFileRequest =
new UploadFileRequest(secondDocumentContent, fileName2, null);
wordsApi.uploadFile(uploadSecondFileRequest);
// Compare documents in cloud.
CompareData compareDataOptions = new CompareData();
compareDataOptions.setAuthor("author");
compareDataOptions.setFileReference(new FileReference(fileName2));
CompareDocumentRequest compareDocumentRequest =
new CompareDocumentRequest(fileName1, compareDataOptions,
null, null, null, null, null, fileResult, null);
wordsApi.compareDocument(compareDocumentRequest);
// Download result document from cloud storage.
DownloadFileRequest downloadFileRequest = new DownloadFileRequest(fileResult, null, null);
byte[] downloadFileResult = wordsApi.downloadFile(downloadFileRequest);
Files.write(Paths.get(fileResult), downloadFileResult.values().iterator().next());
Install 'Aspose.Words Cloud SDK for Java' using Maven build automation tool.
Add this dependency to your project's POM:
As an alternative, you can clone Aspose.Words Cloud SDK for Java source code from GitHub and use it in your project. Please follow these Instructions to quickly get the necessary security credentials and access our REST API.
Refer to the Repository Documentation to see the details.
You can perform compare operation for other file formats: