# Accept or Reject revisions Following this guide, you will learn how to apply or discard revisions found during document comparison using built-in Microsoft Word functionality. [GroupDocs.Comparison](https://products.groupdocs.com/comparison/java) allows you to get revisions from a Docx file format, process, and save the processing result. To take revisions from a document, accept / reject revisions, and write the processing result to the output file, follow these steps: 1. Instantiate the [RevisionHandler](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisionhandler/) object. Specify the source document path or stream. 2. Call the [getRevisions](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisionhandler/#getRevisions--) method to get the revision list. 3. Call the [setAction](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisioninfo/#getAction--) property of the object to be changed. Specify the [RevisionAction.ACCEPT](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisionaction/#ACCEPT) or [RevisionAction.REJECT](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisionaction/#REJECT) value. 4. Call the [applyRevisionChanges](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisionhandler/#applyRevisionChanges-com.groupdocs.comparison.words.revision.ApplyRevisionOptions-) method. Specify the created instance of the [ApplyRevisionOptions](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/applyrevisionoptions/) class and path or stream of the output document, collecting changes in the revisions. You can process all changes together within one action.To handle all changes at once, follow these steps: 1. Instantiate the [RevisionHandler](https://reference.groupdocs.com/comparison/java/groupdocs.comparison.words.revision/revisionhandler) object. Specify the source document path or stream. 2. Call the [applyRevisionChanges](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisionhandler/#applyRevisionChanges-com.groupdocs.comparison.words.revision.ApplyRevisionOptions-) method. Specify the [ApplyRevisionOptions](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/applyrevisionoptions/) object and one of the ([RevisionAction.Accept](https://reference.groupdocs.com/comparison/java/groupdocs.comparison.words.revision/revisionaction), [RevisionAction.Reject](https://reference.groupdocs.com/comparison/java/groupdocs.comparison.words.revision/revisionaction) or [RevisionAction.NONE](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisionaction/#NONE)) values. The main properties of the [ApplyRevisionOptions](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/applyrevisionoptions/) class are as follows: * [Changes](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/applyrevisionoptions/#getChanges--) is a list of revision changes that need to be applied to the final document * [CommonHandler](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/applyrevisionoptions/#getCommonHandler--) allows you to define one action to handle all revision If you do not specify the path or file to the output document for the [applyRevisionChanges](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.words.revision/revisionhandler/#applyRevisionChanges-com.groupdocs.comparison.words.revision.ApplyRevisionOptions-) method, the source file is rewritten. The following code snippets show how to get revisions from a document, accept / reject detected revisions and save changes to the output document: ## Accept or Reject revisions from local disk {{< tabs "example1">}} {{< tab "Java" >}} ```java import com.groupdocs.comparison.words.revision.*; import java.util.List; // ... try (RevisionHandler revisionHandler = new RevisionHandler(withRevisionFile)) { List revisionList = revisionHandler.getRevisions(); for (RevisionInfo revision : revisionList) { if (revision.getType() == RevisionType.INSERTION) { revision.setAction(RevisionAction.ACCEPT); } } ApplyRevisionOptions revisionOptions = new ApplyRevisionOptions(); revisionOptions.setChanges(revisionList); revisionHandler.applyRevisionChanges(resultFile, revisionOptions); } ``` {{< /tab >}} {{< /tabs >}} ## Accept or Reject revisions from stream {{< tabs "example2">}} {{< tab "Java" >}} ```java import com.groupdocs.comparison.words.revision.*; import java.util.List; import java.io.FileInputStream; import java.io.InputStream; import java.io.FileOutputStream; import java.io.OutputStream; // ... try (RevisionHandler revisionHandler = new RevisionHandler(withRevisionInputStream)) { List revisionList = revisionHandler.getRevisions(); for (RevisionInfo revision : revisionList) { if (revision.getType() == RevisionType.Insertion) { revision.setAction(RevisionAction.Accept); } } ApplyRevisionOptions revisionOptions = new ApplyRevisionOptions(revisionList); revisionHandler.applyRevisionChanges(resultOutputStream, revisionOptions); } ``` {{< /tab >}} {{< /tabs >}} ## Accept or Reject all revisions {{< tabs "example3">}} {{< tab "Java" >}} ```java import com.groupdocs.comparison.words.revision.*; // ... try (RevisionHandler revisionHandler = new RevisionHandler(withRevisionFile)) { ApplyRevisionOptions revisionOptions = new ApplyRevisionOptions(); revisionOptions.setCommonHandler(RevisionAction.Accept); revisionHandler.applyRevisionChanges(resultFile, revisionOptions); } ``` {{< /tab >}} {{< /tabs >}} ## Result of revision processing Below are the source and output files based on the code presented earlier. | Source file | Result file | | --------------------------------------------- | ---------------------------------------------------- | | ![](https://docs.groupdocs.com/comparison/java/images/revision-file.png) | ![](https://docs.groupdocs.com/comparison/java/images/result-revision-file.png) |