rt
package zh.codegym.task.task17.task1721;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/*
事务性
*/
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 cur = new Solution();
cur.joinData();
}
public void joinData() throws CorruptedDataException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String s1 = reader.readLine();
String s2 = reader.readLine();
BufferedReader read = new BufferedReader(new FileReader(s1));
String str;
while ((str = read.readLine()) != null) allLines.add(str);
read.close();
read = new BufferedReader(new FileReader(s2));
while ((str = read.readLine()) != null) linesForRemoval.add(str);
read.close();
boolean flag = true;
for(String s : linesForRemoval){
if(!allLines.contains(s)) {
flag = false;
break;
}
}
if(!flag)
{
allLines.clear();
throw new CorruptedDataException();
}else{
for(String s : linesForRemoval){
allLines.remove(s);
}
}
} catch (IOException e) {
throw new CorruptedDataException();
}finally {
try {
reader.close();
} catch (IOException e) {
throw new CorruptedDataException();
}
}
}
}