浏览量 4576
2014/03/14 18:08
package iO;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
public class Exr {
public void Compare(File file1,File file2){
try {
Date l1= new Date(file1.lastModified());
Date l2= new Date(file2.lastModified());
System. out .println(l1+" " +l2);
FileReader fr1= new FileReader(file1);
FileReader fr2= new FileReader(file2);
BufferedReader br2= new BufferedReader (fr2);
BufferedReader br1= new BufferedReader (fr1);
String s1= null ;
String s= null;
while ((s=br1.readLine())!= null){
s1=br2.readLine();
if (s.equals(s1)){
System. out .print(s+"\t" );
System. out .println(s1);}
else {
System. out .print(s+"\t" );
System. out .println(s1+"<--此行被更改了" ); }
}
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
public static void main(String[] args) {
Exr ex= new Exr();
ex.Compare( new File( "d:\\123.txt" ), new File("d:\\1222.txt" ));
}
}
50504501 50504501
50504502 50504502
50504503 50504503
50504504 50504504
50504505 50504505
50504506 50504506
50504507 50504507
50504508 50504508
50504509 50504509
50504510 50504510
50504511 505045113<--此行被更改了
50504512 50504512
50504513 50504513