X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Ftest%2Fsrc%2Ftest%2Futil%2FDiff.java;fp=dol%2Ftest%2Fsrc%2Ftest%2Futil%2FDiff.java;h=dd0f73ecca087911ab7c88f46c3675ebc2d9340b;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/test/src/test/util/Diff.java b/dol/test/src/test/util/Diff.java new file mode 100644 index 0000000..dd0f73e --- /dev/null +++ b/dol/test/src/test/util/Diff.java @@ -0,0 +1,46 @@ +package test.util; + +import java.io.BufferedReader; +import java.io.FileReader; + +/** + * Class to diff two files + */ +public class Diff { + + /** + * Main. + * + * @param args names of the two files to compare + */ + public static void main(String[] args) throws Exception { + if (args.length != 2) { + //System.out.println("Usage: java Diff file1 file2"); + throw new Exception("Usage: java Diff file1 file2"); + } + + try { + BufferedReader fileOneReader = new BufferedReader(new FileReader(args[0])); + BufferedReader fileTwoReader = new BufferedReader(new FileReader(args[1])); + + String lineOne, lineTwo; + while ((lineOne = fileOneReader.readLine()) != null) { + lineTwo = fileTwoReader.readLine(); + if (lineTwo == null) + throw new Exception("Files are not equal: " + + args[1] + " is shorter."); + else if (!lineOne.equals(lineTwo)) + throw new Exception("Files do not match."); + } + + if ((lineTwo = fileTwoReader.readLine()) != null) + throw new Exception("Files are not equal: " + + args[0] + " is shorter."); + } + catch (Exception e) { + throw e; + } + + //System.out.println("Files are equal."); + } +}