Блять, я второй

← разместить еще код

Расшаренный код:

package com.javarush.task.task17.task1721;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Solution {
    public static List<String> allLines = new ArrayList<>();
    public static List<String> forRemoveLines = new ArrayList<>();

    public static void main(String[] args) throws CorruptedDataException {
        try {
            BufferedReader filename = new BufferedReader(new InputStreamReader(System.in));

            FileInputStream fstream1 = new FileInputStream(filename.readLine());
            BufferedReader br1 = new BufferedReader(new InputStreamReader(fstream1));

            FileInputStream fstream2 = new FileInputStream(filename.readLine());
            BufferedReader br2 = new BufferedReader(new InputStreamReader(fstream2));

            String strLine;

            while ((strLine = br1.readLine()) != null) {
                allLines.add(strLine);
            }

            while ((strLine = br2.readLine()) != null) {
                forRemoveLines.add(strLine);
            }

            filename.close();

            fstream1.close();
            fstream2.close();
            br1.close();
            br2.close();

        } catch (IOException e) {
            System.out.println("ERROR!!");
        }

        Solution s = new Solution();
        s.joinData();
    }

    public void joinData() throws CorruptedDataException {
        if (allLines.containsAll(forRemoveLines)) {
            allLines.removeAll(forRemoveLines);
        } else {
            allLines.clear();
            throw new CorruptedDataException();
        }
    }
}