Все просто, ошибки быть не может? На что ругается валидатор?
package com.javarush.task.task19.task1916;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Отслеживаем изменения
*/
public class Solution {
public static List<LineItem> lines = new ArrayList<LineItem>();
public static void main(String[] args) throws IOException {
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
String name1 = rd.readLine();
String name2 = rd.readLine();
rd.close();
BufferedReader readerOne = new BufferedReader(new FileReader(name1));
BufferedReader readerTwo = new BufferedReader(new FileReader(name2));
String line1 = "";
String line2 = "";
ArrayList<String> fileOne = new ArrayList<>();
ArrayList<String> fileTwo = new ArrayList<>();
Map<String, Integer> map = new TreeMap<>();
while ((line1 = readerOne.readLine()) != null) {
fileOne.add(line1);
map.put(line1, 1);
}
while ((line2 = readerTwo.readLine()) != null) {
fileTwo.add(line2);
if (map.containsKey(line2)) {
map.put(line2, 2);
} else {map.put(line2, 1);}
}
readerOne.close();
readerTwo.close();
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 2) {
lines.add(new LineItem(Type.SAME, entry.getKey()));
} else {
if (fileOne.contains(entry.getKey())) {lines.add(new LineItem(Type.REMOVED, entry.getKey()));}
if (fileTwo.contains(entry.getKey())) {lines.add(new LineItem(Type.ADDED, entry.getKey()));}
}
}
}
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;
}
}
}