Прошу совета
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) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedReader fr1 = new BufferedReader(new FileReader(br.readLine()));
BufferedReader fr2 = new BufferedReader(new FileReader(br.readLine()));
br.close();
while (fr2.ready()){
if (!fr1.ready()){
lines.add(new LineItem(Type.ADDED, fr2.readLine()));
continue;
}
fr1.mark(10000);
String string101 = fr1.readLine();
fr2.mark(10000);
String string201 = fr2.readLine();
String string202 = fr2.readLine();
if (string101.equals(string201)) {
lines.add(new LineItem(Type.SAME, string101));
}
else if (string101.equals(string202)) {
lines.add(new LineItem(Type.ADDED, string201));
fr1.reset();
}
else {
lines.add(new LineItem(Type.REMOVED, string101));
fr2.reset();
}
}
while (fr1.ready()){
lines.add(new LineItem(Type.REMOVED, fr1.readLine()));
}
fr1.close();
fr2.close();
}
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;
}
}
}