можете подсказать или тестовые данные в локальных файлах вроде все работает
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.ArrayList;
import java.util.List;
/*
Отслеживаем изменения
*/
public class Solution {
public static List<LineItem> lines = new ArrayList<LineItem>();
public static void main(String[] args) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); BufferedReader in1 = new BufferedReader(new FileReader(reader.readLine()));
BufferedReader in2 = new BufferedReader(new FileReader(reader.readLine())) ) {
List<String> strings1 = readLines(in1); List<String> strings2 = readLines(in2);
int i = 0;
int j = 0;
while (true) { if (i == strings1.size()) {
for (int k = j; k < strings2.size(); k++) { lines.add(new LineItem(Type.REMOVED, strings2.get(k)));
} break;
} else if (j == strings2.size()) { for (int k = i; k < strings1.size(); k++) {
lines.add(new LineItem(Type.REMOVED, strings1.get(k))); }
break; }
String f1 = strings1.get(i); String f2 = strings2.get(j);
if (f1.equals(f2)) {
lines.add(new LineItem(Type.SAME, f1)); i++;
j++; } else if (!f1.equals(f2)) {
String f11 = strings1.get(i+1); String f22 = strings2.get(j+1);
if (f11.equals(f2)) { lines.add(new LineItem(Type.REMOVED, f1));
i++; } else if (f1.equals(f22)) {
lines.add(new LineItem(Type.ADDED, f2)); j++;
} }
} } catch (IOException e) {
throw new RuntimeException(e); }
}
private static List<String> readLines(BufferedReader in) throws IOException { List<String> strings = new ArrayList<>();
String s = "";
while ((s = in.readLine()) != null) {
strings.add(s); }
return strings;
}
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;
}
}
}