1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| package com.javatpoint;
import java.io.BufferedReader;
import java.nio.file.Files;
import java.nio.file.Paths;
public class test6 {
public static void main(String[] argv) throws Exception {
try
(BufferedReader reader1 = Files.newBufferedReader(Paths.get("C:\\Intel\\fichier.txt") );
BufferedReader reader2 = Files.newBufferedReader(Paths.get( "C:\\Intel\\fichier2.txt") );
) {
int tot=0;
String line1;
String line2;
while((line1 = reader1.readLine())!=null && (line2 = reader2.readLine())!=null) {
// comparer line1 et line2
String[] nombres1 = line1.split("\\s");
String[] nombres2 = line2.split("\\s");
// on compare le 1er nombre de la ligne du fichier 1 avec le 1er nombre de la ligne du fichier 2
// puis le 2ième nombre de la ligne du fichier 1 avec le 2ième nombre de la ligne du fichier 2
// puis le 3ième, etc
for(int i=1; i<nombres1.length;i++)
{
for (int y=1;y<nombres2.length; y++ ) {
System.out.println(nombres1[i]);
System.out.println(nombres2[y]);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
{
}
System.out.println(" test ");
System.out.println(nombres1[i+1]);
System.out.println(nombres2[i+1]);
//System.out.println(i);
// System.out.println(" fin");
if ( nombres1[i+1].equals(nombres2[i+1]) ) {
// System.out.println(" test ");
//System.out.println(i);
// System.out.println(" fin");
// les deux nombres sont égaux
if (i>0) {
tot++;
}
// System.out.println(tot);
}
//System.out.println(line1);
//System.out.println(line2);
// comparer line1 et line2
}
}
}
}
} |
Partager