One condition is not met, it shows and in validation is a message saying that the program won't throw CorruptedDataException, but it throws it. Where is the problem?
package pl.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.Iterator;
import java.util.List;
/*
Transakcyjność
*/
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 reader = new BufferedReader(new InputStreamReader(System.in));
String file1 = reader.readLine();
String file2 = reader.readLine();
reader.close();
FileReader fr1 = new FileReader(file1);
FileReader fr2 = new FileReader(file2);
BufferedReader bfr1 = new BufferedReader(fr1);
BufferedReader bfr2 = new BufferedReader(fr2);
while (bfr1.ready()){
allLines.add(bfr1.readLine());
}
while (bfr2.ready()){
linesForRemoval.add(bfr2.readLine());
}
Solution s = new Solution();
s.joinData();
fr1.close();
fr2.close();
bfr1.close();
bfr2.close();
}
boolean hasit = false;
public void joinData() throws CorruptedDataException {
for (int i = 0; i < linesForRemoval.size(); i++) {
hasit = false;
for (int j = 0; j < allLines.size(); j++) {
if (linesForRemoval.get(i).equals(allLines.get(j)));
hasit = true;
}
if (hasit = false){
for(Iterator<String> it = allLines.iterator(); it.hasNext(); )
{
String temp = it.next();
it.remove();
}
throw new CorruptedDataException();
}
}
for (int i = 0; i < linesForRemoval.size(); i++) {
for(Iterator<String> it = allLines.iterator(); it.hasNext(); )
{
String temp = it.next();
if (linesForRemoval.get(i).equals(temp))
it.remove();
}
}
}
}