Hi.
Can anyone help me please ? It works fine on IDE, but it fails at 5 - 8
package com.codegym.task.task17.task1721;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
/*
Transactionality
*/
public class Solution {
public static List<String> allLines = new ArrayList<>();
public static List<String> linesForRemoval = new ArrayList<>();
public static void main(String[] args) {
Solution s = new Solution();
try {
s.joinData();
}
catch (IOException e)
{
}
}
public void joinData() throws IOException {
FileInputStream fis1 = null;
FileInputStream fis2 = null;
String st;
boolean b = true;
while(b) {
BufferedReader reader1 = new BufferedReader(new InputStreamReader(System.in));
BufferedReader reader2 = new BufferedReader(new InputStreamReader(System.in));
String filename1 = reader1.readLine();
String filename2 = reader2.readLine();
fis1 = new FileInputStream(filename1);
fis2 = new FileInputStream(filename2);
reader1 = new BufferedReader(new InputStreamReader(fis1));
while ((st = reader1.readLine()) != null) {
allLines.add(st);
}
reader1.close();
fis1.close();
reader2 = new BufferedReader(new InputStreamReader(fis2));
while ((st = reader2.readLine()) != null) {
linesForRemoval.add(st);
}
reader2.close();
fis2.close();
if (allLines.containsAll(linesForRemoval)) {
allLines.removeAll(linesForRemoval);
} else {
allLines.clear();
throw new CorruptedDataException();
}
}
}
}
package com.codegym.task.task17.task1721;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
/*
Transactionality
*/
public class Solution {
public static List<String> allLines = new ArrayList<>();
public static List<String> linesForRemoval = new ArrayList<>();
public static void main(String[] args) throws CorruptedDataException{
Solution s = new Solution();
s.joinData();
}
public void joinData() throws CorruptedDataException {
FileInputStream fis1 = null;
FileInputStream fis2 = null;
String st;
boolean b = true;
while(b) {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String filename1 = reader.readLine();
String filename2 = reader.readLine();
fis1 = new FileInputStream(filename1);
fis2 = new FileInputStream(filename2);
reader = new BufferedReader(new InputStreamReader(fis1));
while ((st = reader.readLine()) != null) {
allLines.add(st);
}
reader = new BufferedReader(new InputStreamReader(fis2));
while ((st = reader.readLine()) != null) {
linesForRemoval.add(st);
}
if (allLines.containsAll(linesForRemoval)) {
allLines.removeAll(linesForRemoval);
} else {
allLines.clear();
throw new CorruptedDataException();
}
b = false;
reader.close();
fis1.close();
fis2.close();
} catch (IOException e) {
}
}
}
}