То ли я условие правильно не понимаю... Работает вроде бы как нужно, но валидатор ругается. Что не так, подскажите...
package com.javarush.task.task19.task1916;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.Buffer;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
/*
Отслеживаем изменения
*/
public class Solution {
public static List<LineItem> lines = new ArrayList<LineItem>();
public static void main(String[] args) {
try (BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
BufferedReader reader1 = new BufferedReader(new FileReader(r.readLine()));
BufferedReader reader2 = new BufferedReader(new FileReader(r.readLine()))) {
String s;
List<String> list1 = new ArrayList<>();
List<String> list2 = new ArrayList<>();
while ((s = reader1.readLine()) != null) {
list1.add(s);
}
while ((s = reader2.readLine()) != null) {
list2.add(s);
}
for (int i = 0; i < list1.size(); i++) {
if (list2.contains(list1.get(i))) {
lines.add(new LineItem(Type.SAME, list1.get(i)));
list2.remove(list1.get(i));
} else {
lines.add(new LineItem(Type.REMOVED, list1.get(i)));
}
}
for (String str : list2) {
lines.add(new LineItem(Type.ADDED, str));
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static enum Type {
ADDED, //добавлена новая строка
REMOVED, //удалена строка
SAME //без изменений
}
public static class LineItem {
public Type type;
public String line;
public LineItem(Type type, String line) {
this.type = type;
this.line = line;
}
}
}