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:
<blockquote>
diff d = new diff(file1,file2);</blockquote>
which is equivalent to:
<blockquote>
diff d = new diff(); d.diffFile(file1,file2);</blockquote>
To compare two BufferedReaders or two String we have to instanciate as follows:
<blockquote>
diff d = new diff(); d.diffBuffer(BufferedReader1,BufferedReader2);</blockquote>
or:
<blockquote>
diff d = new diff(); d.diffString(String1,String2);</blockquote>
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:
<blockquote>
diff d=new diff(args[0],args[1]);
d.print();
d.save("diff.txt");
</blockquote>Example using BufferedReader and ED_format:
<blockquote>
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");
</blockquote>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.
<blockquote>
Vector v=d.getHunk();
for(Enumeration e=v.element();e.hasMoreElements(); )
{
System.out.print(((Hunk)e.nextElement()).convert());
}
</blockquote>or:
<blockquote>
diff d = new diff(file1,file2);
for(int i=0; i<d.numberOfHunk(); i++){
Object k=d.hunkAt(i);
if(k instanceof Hunk)
System.out.print(k.convert());
}
</blockquote>
diff.diff#hunkAt()
diff.diff#numberOfHunk()
diff.diff#print()
diff.diff#print_ED()
diff.diff#print_RCS()
diff.diff#save()
diff.diff#save_ED()
diff.diff#save_RCS() </summary>
Definition at line 82 of file diff.cs.
1.3.9.1