Застрял, пробовал многими способами... не могу понять что не так с этим решением
package com.javarush.task.task13.task1326;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
/*
Сортировка четных чисел из файла
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String nameFile = reader.readLine();
FileInputStream source = new FileInputStream(nameFile);
int i;
String x = "";
ArrayList<Integer> list = new ArrayList<>();
while((i = source.read()) != -1){
if(i != 10){
if(i == 13){
list.add(Integer.parseInt(x));
x = "";
}else{
x = x + (char) i;
}
}
}
reader.close();
source.close();
list.add(Integer.parseInt(x));
Collections.sort(list);
for (int j = 0; j < list.size(); j++) {
if(list.get(j) % 2 == 0){
System.out.println(list.get(j));
}
}
}
}