подскажите почему ждет ввод в консоль третьей строчки...вроде 2 считываю и закрываю
package com.javarush.task.task19.task1916;
import java.io.*;
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 fileName1 = reader.readLine();
String fileName2 = reader.readLine();
reader.close();
try (BufferedReader br1 = new BufferedReader(new FileReader(fileName1));
BufferedReader br2 = new BufferedReader(new FileReader(fileName2))) {
String line1;
String line2;
ArrayList<String> list1=new ArrayList<>();
ArrayList<String> list2=new ArrayList<>();
while ((line1 = br1.readLine()) != null) {
list1.add(line1);
}
while ((line2 = br2.readLine()) != null) {
list2.add(line2);
}
while (list1.size() >0&&list2.size() >0) {
if (list1.get(0).equals(list2.get(0))) {
lines.add(new LineItem(Type.SAME, list1.get(0)));
} if (list1.get(1).equals(list2.get(0))) {
lines.add(new LineItem(Type.REMOVED, list1.get(1)));
list1.remove(1);
} if (list1.get(0).equals(list2.get(1))) {
lines.add(new LineItem(Type.ADDED, list2.get(1)));
list2.remove(1);
}
}
if(list1.isEmpty() && !list2.isEmpty()) {
lines.add(new LineItem(Type.ADDED, list2.get(0)));
}
if(list2.isEmpty() && !list1.isEmpty()) {
lines.add(new LineItem(Type.REMOVED, list1.get(0)));
}
}
}
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;
}
}
}