Почему-то говорит, что листы не наполняются.
package com.javarush.task.task17.task1721;
import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/*
Транзакционность
*/
public class Solution {
public static List<String> allLines = new ArrayList<String>();
public static List<String> forRemoveLines = new ArrayList<String>();
public static void main(String[] args) {
BufferedReader bfReader = new BufferedReader(new InputStreamReader(System.in));
Solution sol = new Solution();
try {
String file1 = bfReader.readLine();
String file2 = bfReader.readLine();
bfReader.close();
BufferedReader flReader = new BufferedReader(new FileReader(file1));
while(true) {
String data = flReader.readLine();
if (data.equals(null)) {
flReader.close();
break;
}
Solution.allLines.add(data);
}
BufferedReader flReader2 = new BufferedReader(new FileReader(file2));
while(true) {
String data = flReader2.readLine();
if (data.equals(null)) {
flReader2.close();
break;
}
Solution.forRemoveLines.add(data);
}
sol.joinData();
} catch (FileNotFoundException e) {
System.out.println(e);
} catch (CorruptedDataException e) {
} catch (IOException e) {}
}
public void joinData() throws CorruptedDataException {
if (Solution.allLines.containsAll(Solution.forRemoveLines)) {
Iterator allLinesIter = Solution.allLines.iterator();
while(allLinesIter.hasNext()) {
String s = (String) allLinesIter.next();
boolean isPresent = false;
for (String s2 : Solution.forRemoveLines) {
if (s.equals(s2)) {
isPresent = true;
break;
}
}
if (isPresent) {
allLinesIter.remove();
}
}
} else {
Solution.allLines.clear();
throw new CorruptedDataException();
}
}
}