What's wrong in my code?
Input:
5
8
-2
11
3
-5
2
10
My output:
10
10
10
10
10
10
10
10
48
50
50
56
package com.codegym.task.task13.task1326;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
/*
Sorting even numbers from a file
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String filename = reader.readLine();
FileInputStream fileInputStream = new FileInputStream(filename);
ArrayList<Integer> list = new ArrayList<>();
try {
while (fileInputStream.available() > 0) {
int i = fileInputStream.read();
list.add(i);
}
fileInputStream.close();
reader.close();
} catch (Exception e) {
System.out.println(e);
}
Collections.sort(list);
for (int num : list) {
if (num % 2 == 0) System.out.println(num);
}
}
}