Recipe 4.5 Comparing Files

     

4.5.1 Problem

You need to see the differences between two files displayed graphically.

4.5.2 Solution

Select the files in a view and then select Compare With Each Other in the view's context menu.

4.5.3 Discussion

One of the most common things professional developers need to do is to compare the contents of two files to see the changes made to each; the support in most operating systems for such operations is minimal.

To compare two files, highlight them in a view such as the Package Explorer and select Compare With Each Other in the view's context menu. Eclipse will perform the comparison in an intelligent manner and display the results in a Compare Editor, as shown in Figure 4-10.

Figure 4-10. Comparing two files
figs/ecb_0410.gif

You even can edit the files, copying changes from one file to the other using the buttons in the Java Source Compare pane.

You can ignore comments and formatting changes when performing the comparisons: click the Ignore Whitespace option in the Compare Editor's toolbar button (that's the fourth button from the right in the main toolbar in Figure 4-10). This is useful when working with XML.


4.5.4 See Also

Recipe 4.6 on comparing files against local history; Recipe 4.7 on restoring elements and files from local history.



Eclipse Cookbook
Inside XML (Inside (New Riders))
ISBN: 596007108
EAN: 2147483647
Year: 2006
Pages: 232
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net