I need help , the logic is right , the everything is right , why it is happen ?
The seventh requirement;
package com.codegym.task.task17.task1721;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/*
Transactionality
*/
public class Solution {
public static List<String> allLines = new ArrayList<>();
public static List<String> linesForRemoval = new ArrayList<>();
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String file1 = " ";
String file2 = " ";
// 1. Read from the console 2 file names;
try {
file1 = br.readLine();
file2 = br.readLine();
}catch (IOException e){
System.out.println(e);
}
// 2. Read from the files line by line.
try {
BufferedReader readFile1 = new BufferedReader(new FileReader(file1));
String line = readFile1.readLine();
while (line != null){
allLines.add(line);
line = readFile1.readLine();
}
readFile1.close();
}
catch (IOException e){
System.out.println(e);
}
try {
BufferedReader readFile2 = new BufferedReader(new FileReader(file2));
String line = readFile2.readLine();
while (line != null){
linesForRemoval.add(line);
line = readFile2.readLine();
}
readFile2.close();
}catch (IOException e){
System.out.println(e);
}
try {
new Solution().joinData();
}catch (CorruptedDataException e){
System.out.println(e);
}
}
public void joinData() throws CorruptedDataException {
// 3 f the allLines list contains all the lines from linesForRemoval,
// then remove from the allLines list all the lines that are in linesForRemoval.
if (allLines.containsAll(linesForRemoval)){
allLines.removeAll(linesForRemoval);
}
else
allLines.clear();
throw new CorruptedDataException();
}
}