First page Back Continue Last page Overview Graphics
Final Example: An easy way to detect foolish copying - Diff
import java.io.*;
public class Diff {
public static void main(String[] args){
//check for arguments
if(args.length !=2){
System.out.println("Usage: java Diff <file1> <file2>");
System.exit(0);
}
//used for comparing the files textually line by line
LineNumberReader file1In,file2In;
//set to false if the files are different
boolean noDiff= true;
//used to keep all differences found between the 2 files.
StringBuffer output= new StringBuffer();
try{
file1In= new LineNumberReader(new FileReader(args[0]));
file2In= new LineNumberReader(new FileReader(args[1]));