2 conditions don't verify for some reason. Some help, please!
package com.codegym.task.task17.task1721;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
7. The joinData method must remove from the allLines list all lines
in the linesForRemoval list if allLines contains all the lines in the linesForRemoval list.
8. The joinData method must clear the allLines list and throw a CorruptedDataException,
if allLines does not contain all the lines in the linesForRemoval list.
9. The joinData method should be called in main.
C:\\Users\\40742\\Desktop\\BIOCHIMIE1.txt
C:\\Users\\40742\\Desktop\\BIOCHIMIE2.txt
*/
public class Solution {
public static List<String> allLines = new ArrayList<>();
public static List<String> linesForRemoval = new ArrayList<>();
public static void main(String[] args) throws IOException {
BufferedReader buffer1 = new BufferedReader(new InputStreamReader(System.in));
String fileName1 = buffer1.readLine();
String fileName2 = buffer1.readLine();
BufferedReader buffer = new BufferedReader(new FileReader(fileName1));
String readFirstFile = buffer.readLine();
while (readFirstFile != null) {
allLines.add(readFirstFile);
readFirstFile = buffer.readLine();
}
buffer = new BufferedReader(new FileReader(fileName2));
String readSecondFile = buffer.readLine();
while (readSecondFile != null) {
linesForRemoval.add(readSecondFile);
readSecondFile = buffer.readLine();
}
buffer.close();
Solution sol = new Solution();
sol.joinData();
}
public void joinData() throws CorruptedDataException {
ArrayList<String> array = new ArrayList<>(allLines);
for (int i = 0; i < linesForRemoval.size(); i++) {
if (allLines.get(i).equals(linesForRemoval.get(i))) {
} else
allLines.clear();
throw new CorruptedDataException();
}
for (int i = 0; true; i++) {
if (linesForRemoval.get(i).equals(array.get(i))) {
System.out.println(i);
allLines.remove(i);
}
}
}
}