# Get source and target text from files This article explains how to get source and target texts of specific changes using GroupDocs.Comparison for Java. [GroupDocs.Comparison](https://products.groupdocs.com/comparison/java) allows you to get source and target texts of specific changes in the output file. To get a list of changed source and target texts, follow these steps: 1. Instantiate the [Comparer](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer) object. Specify the source document path or stream. 2. Call the [add()](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer/#add-java.lang.String-) method. Specify the target document path or stream. 3. Call the [compare()](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer/#compare-java.lang.String-) method. 4. Call the [getChanges()](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer/#getChanges--) method. The following code snippets show how to get specified texts from a file. ## Get source and target text from local disk {{< tabs "example1">}} {{< tab "Java" >}} ```java import com.groupdocs.comparison.Comparer; import com.groupdocs.comparison.result.ChangeInfo; import java.nio.file.Path; // ... try (Comparer comparer = new Comparer("source.docx")) { comparer.add("target.docx"); final Path resultPath = comparer.compare("result.docx"); ChangeInfo[] changes = comparer.getChanges(); for (ChangeInfo change : changes) { System.out.println(); System.out.println("Source text: " + change.getSourceText()); System.out.println("Target text: " + change.getTargetText()); } } ``` {{< /tab >}} {{< /tabs >}} The result is as follows: ![](https://docs.groupdocs.com/comparison/java/images/get-source-and-target-text-from-files.png) ## Get source and target text from stream {{< tabs "example2">}} {{< tab "Java" >}} ```java import com.groupdocs.comparison.Comparer; import com.groupdocs.comparison.result.ChangeInfo; import java.nio.file.Path; import java.io.FileInputStream; import java.io.InputStream; // ... try (Comparer comparer = new Comparer(sourceInputStream)) { comparer.add(targetInputStream); final Path resultPath = comparer.compare("result.docx"); ChangeInfo[] changes = comparer.getChanges(); for (ChangeInfo change : changes){ System.out.println(); System.out.println("Source text: "+change.getSourceText()); System.out.println("Target text: "+change.getTargetText()); } } ``` {{< /tab >}} {{< /tabs >}}