Підкажіть, що не так?
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 reader = new BufferedReader(new InputStreamReader(System.in));
String nameFile_1 = reader.readLine(); // "C:\\DiskD\\jav\\er3.txt";
String nameFile_2 = reader.readLine(); // "C:\\DiskD\\jav\\er3-m2.txt";
BufferedReader reader1 = new BufferedReader(new FileReader(nameFile_1));
BufferedReader reader2 = new BufferedReader(new FileReader(nameFile_2));
ArrayList<String> arrayList_1 = new ArrayList<>();
ArrayList<String> arrayList_2 = new ArrayList<>();
String line = "";
while ((line = reader1.readLine()) != null) {
arrayList_1.add(line);
}
while ((line = reader2.readLine()) != null) {
arrayList_2.add(line);
}
int t = 0;
String a = "";
String b = "";
String a_1 = "";
String b_1 = "";
String b_2 = "";
int max_arr = arrayList_1.size() >= arrayList_2.size() ? arrayList_1.size() : arrayList_2.size();
for (int i = 0; i < max_arr; i++) {
try {
a = arrayList_1.get(i);
} catch (IndexOutOfBoundsException e) {
a = "";
}
try {
b_1 = arrayList_2.get(t - 1);
} catch (IndexOutOfBoundsException e) {
b_1 = "";
}
try {
b = arrayList_2.get(t);
} catch (IndexOutOfBoundsException e) {
b = "";
}
try {
b_2 = arrayList_2.get(t + 1);
} catch (IndexOutOfBoundsException e) {
b_2 = "";
}
if (!a.equals(b_1) & !a.equals(b) & !a.equals(b_2)) {
//System.out.println(a + " " + " " + Type.REMOVED + " " + a);
lines.add(new LineItem(Type.REMOVED, a));
}
if (a.equals(b_1) & !a.equals(b) & !a.equals(b_2)) {
//System.out.println(a + " " + b + " " + Type.SAME + " " + a);
lines.add(new LineItem(Type.SAME, a));
}
if (!a.equals(b_1) & a.equals(b) & !a.equals(b_2)) {
//System.out.println(a + " " + b + " " + Type.SAME + " " + a);
lines.add(new LineItem(Type.SAME, a));
t++;
}
if (!a.equals(b_1) & !a.equals(b) & a.equals(b_2)) {
//System.out.println(" " + " " + b + " " + Type.ADDED + " " + b);
lines.add(new LineItem(Type.ADDED, b));
t++;
i--;
}
try {
a_1 = arrayList_1.get(i + 1);
} catch (IndexOutOfBoundsException e) {
a_1 = "";
}
try {
b_1 = arrayList_2.get(t);
} catch (IndexOutOfBoundsException e) {
b_1 = "";
}
if (a_1 == "" & t <= i & b_1 != "") {
//System.out.println(" " + " " + b_1 + " " + Type.ADDED + " " + b_1);
lines.add(new LineItem(Type.ADDED, b_1));
}
/* for (int j = 0; j < lines.size(); j++) {
System.out.println(lines.get(i).line);
}*/
}
reader.close();
reader1.close();
reader2.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;
}
}
}