import java.io.*; public class TextCompare { public static void compare(File f1, File f2) { try { int b=0, line=1, col=1; boolean run=true; Reader bf1, bf2; int buf1=0, buf2=0; bf1 = new BufferedReader(new FileReader(f1)); bf2 = new BufferedReader(new FileReader(f2)); while(run && buf1!=-1 && buf2!=-1) { buf1=bf1.read(); buf2=bf2.read(); if(buf1==buf2) {b++; col++; if(buf1==10) {line++; col=1;} } else { run=false; System.out.println("Unterschied entdeckt an Byte "+b+" Zeile:"+line+" Spalte:"+col); } } if(run==true) { System.out.println("Die Dateien sind gleich!"); } } catch(FileNotFoundException fnfe) { System.out.println("Eine Datei wurde nicht gefunden:\n"+fnfe.getMessage()); } catch(IOException ioe) { System.out.println("IOException!"); } } public static void main(String args[]) { compare(new File(args[0]), new File(args[1])); } }