- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
-
- public class BRDemo {
- public static void main(String args[]) throws IOException{
- String txtPath1 = "C:\\Users\\CH6\\Desktop\\TEDTXTUNICODE\\eng1246";
- String txtPath2 = "C:\\Users\\CH6\\Desktop\\TEDTXTUNICODE\\chs1203";
- File f1 = new File(txtPath1);
- File f2 = new File(txtPath2);
- File fs1[] = null;
- if(f1.isDirectory()){
- fs1 = f1.listFiles((File ff,String name) -> {if(name.endsWith(".txt")){return true;}return false;});
- }
- File fs2[] = null;
- if(f2.isDirectory()){
- fs2 = f2.listFiles((File ff,String name) -> {if(name.endsWith(".txt")){return true;}return false;});
- }
- for(File fa : fs1){
- System.out.println("------------------------");
- System.out.println(fa.getPath());
- for(File fb : fs2){
- if(fa.getName().equals(fb.getName())){
- BufferedReader bra = new BufferedReader(new FileReader(fa));
- BufferedReader brb = new BufferedReader(new FileReader(fb));
- int na = 0;
- int nb = 0;
- String braStr;
- String brbStr;
- while(bra.ready()){
- na++;
- while(brb.ready()){
- nb++;
- if(nb == na){
- System.out.println(bra.readLine() + " " + brb.readLine());
- }
- nb = 0;
- }
- na = 0;
- }
- }
- }
- }
- }
- }
复制代码
|