Подскажите, логика решения сильно хромает?
package com.javarush.task.task17.task1721;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
/*
Транзакционность
*/
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) throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BufferedReader b = new BufferedReader(new FileReader(reader.readLine()));
BufferedReader b1 = new BufferedReader(new FileReader(reader.readLine()));
while(b.ready()){
allLines.add(b.readLine());
}
while(b1.ready()){
forRemoveLines.add(b1.readLine());
}
try{
Solution n = new Solution();
n.joinData();
}
catch(Exception e){
}
b.close();
b1.close();
}
public void joinData() throws CorruptedDataException {
int count = 0;
for(int i = 0; i < allLines.size(); i++){
if (allLines.get(i).equals(forRemoveLines.get(i))) {
count++;
}
}
if(count != forRemoveLines.size()){
while(allLines.get(0) != null){
allLines.remove(0);
}
throw new CorruptedDataException();
}
else{
for(int i = 0; i < allLines.size(); i++){
if(allLines.get(i).equals(forRemoveLines.get(i))){
allLines.remove(i);
}
}
}
}
}