I have two different .txt files as examples: file1.txt has 1854 lines with 6 numbers on each line separated by "" (one space). In the other file2.txt I have more than 1 million lines with 6 numbers on each line separated by "" (a space too). I tried to have the first line of file2.txt look at all the lines in file1.txt by looking for how many equal numbers there are in each line of file1.txt and then move on to the next line of file2.txt and again do the same analysis as was done before, until the end of file2.txt. But the problem is that my code is just parsing the first line of file1.txt with the first line of file2.txt, then jumps to the next line of both files. Can anyone help me crafting this code the way I would like it. The code is as follows:
public class Confere {
public static void main(String[] args) throws FileNotFoundException {
try {
// pega os arquivos txt´s
File file = new File("C:/Users/Usuario/Documents/Vander/mega.txt");
File file2 = new File("C:/Users/Usuario/Documents/Vander/resultadomega.txt");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
FileReader fileReader2 = new FileReader(file2);
BufferedReader bufferedReader2 = new BufferedReader(fileReader2);
while (bufferedReader.ready()) {
bufferedReader2.ready();
String linha = bufferedReader.readLine(); // lê uma linha...
String linha2 = bufferedReader2.readLine(); // lê uma linha...
if (linha.toString().contains(linha2.toString())) { // verifica se as linhas são iguais
System.out.println("igual");
// #####################################################
RandomAccessFile raf = new RandomAccessFile("C:/Users/Usuario/Documents/Vander/relatorio.txt", "rw");
raf.seek(raf.length());
raf.writeBytes(linha + "\r\n");
raf.close();
// ######################################################
System.out.println(linha);
} else {
System.out.println("diferente");
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
I would be very grateful, as it is very difficult ...