The diff class compares two files. it compares also two
BufferedReaders or two strings.
after the comparison the vector will represents a list of hunk
corresponding with blocks of difference.
to generate a file of difference, one can instanciate as follows the class
diff:
diff d = new diff(file1,file2);
which is equivalent to:
diff d = new diff();
d.diffFile(file1,file2);
To compare two BufferedReaders or two String we have to instanciate
as follows:
diff d = new diff();
d.diffBuffer(BufferedReader1,BufferedReader2);
or:
diff d = new diff();
d.diffString(String1,String2);
The class diff includes methods for examining, printing
or saveing blocks of difference: (Hunks).
Here are some more examples of how diff can be used:
diff d=new diff(args[0],args[1]);
d.print();
d.save("diff.txt");
Example using BufferedReader and ED_format:
BufferedReader in=new BufferedReader(new FileReader(args[0]));
BufferedReader inn=new BufferedReader(new FileReader(args[1]));
diff d = new diff();
d.diffBuffer(in,inn);
d.print_ED();
d.save_ED("diff.txt");
To go throw the list of Hunks we can choose between an Enumeration
or a loop by spesifyng index in the vector to get at each time
the corresponding Hunk.
Vector v=d.getHunk();
for(Enumeration e=v.element();e.hasMoreElements(); )
{
System.out.print(((Hunk)e.nextElement()).convert());
}
or:
diff d = new diff(file1,file2);
for(int i=0; i
See Also: diff.diff.getHunk See Also: diff.diff.hunkAt See Also: diff.diff.numberOfHunk See Also: diff.diff.print See Also: diff.diff.print_ED See Also: diff.diff.print_RCS See Also: diff.diff.save See Also: diff.diff.save_ED See Also: diff.diff.save_RCS |