com.finalist.util
Class Diff

java.lang.Object
  extended bycom.finalist.util.Diff

public class Diff
extends java.lang.Object

This class performs a 'diff' on two files: i.e. compares the two files and returns a result containing information about the lines that differ.

NOTE: This diff tool does not use the same algorithm as the familiar command-line diff, so the results will not always be identical.

Author:
Michael O'Connor - Finalist IT Group.

Constructor Summary
Diff(java.io.File file1, java.io.File file2)
          Creates a new Diff, given two files that will be compared.
 
Method Summary
 java.util.List getDiffLines()
          Performs the diff and returns the result as a List of DiffConflictLine objects.
static void main(java.lang.String[] args)
          For testing purposes - I distance off with JUnit, honestly - but it's too slow!
 java.lang.String performDiff()
          Performs the diff on the two files specified in the constructor, returning a formatted human-readable report (HTML, in this case).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Diff

public Diff(java.io.File file1,
            java.io.File file2)
     throws java.io.IOException
Creates a new Diff, given two files that will be compared.

Parameters:
file1 - the first file.
file2 - the second file.
Throws:
java.io.IOException - if either of the files doesn't exist.
Method Detail

performDiff

public java.lang.String performDiff()
                             throws java.io.IOException
Performs the diff on the two files specified in the constructor, returning a formatted human-readable report (HTML, in this case).

Returns:
a String representation of the diff report, or null if the two files were identical (excluding whitespace differences).
Throws:
java.io.IOException - if the files couldn't be read.

getDiffLines

public java.util.List getDiffLines()
                            throws java.io.IOException
Performs the diff and returns the result as a List of DiffConflictLine objects.

Returns:
Throws:
java.io.IOException - if the files couldn't be read.

main

public static void main(java.lang.String[] args)
For testing purposes - I distance off with JUnit, honestly - but it's too slow!

Parameters:
args - [1] file#1, [2] file#2.


Copyright © 2003-2005 SourceForge. All Rights Reserved.