I go trhow file by bites if it is char between 48 -57 i add it in to string and than check, if line finished by (13) i check is number even? yes add to arr.
Than sort array and show it on display.
All works, but task don't accepted it.
Can you help please?
package com.codegym.task.task13.task1326;
/*
Sorting even numbers from a file
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = reader.readLine();
FileInputStream fileIn = new FileInputStream(str);
String strSt = "";
int check = 0;
int numIn = 0;
int num = fileIn.read();
int county = 0;
ArrayList<Integer> arr = new ArrayList<>();
while (fileIn.available() > 0) {
if(county != 0) {
num = fileIn.read();
}else{
county++;
}
if (num > 47 && num < 58 || num == 45 ) {
if(num == 45){
strSt = "-";
}else {
numIn = num - 48;
strSt = strSt + "" + numIn;
check = Integer.parseInt(strSt);
}
} else if (num == 13 && check%2==0) {
arr.add(check);
strSt = "";
check = 0;
}
else if(num == 10){
strSt = "";
check = 0;
}
}
reader.close();
fileIn.close();
Collections.sort(arr);
for(Integer iny : arr){
System.out.println(iny);
}
}
}