Something goes wrong, but I have no idea what :/
package pl.codegym.task.task18.task1822;
/*
Wyszukiwanie danych wewnątrz pliku
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws IOException {
int id = Integer.parseInt(args[0]);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream fileInputStream = new FileInputStream(bufferedReader.readLine());
String line = "";
while (fileInputStream.available()>0) {
int c = fileInputStream.read();
if ( c == 13) {
String[] s = line.trim().split(" ");
int lineID = Integer.parseInt(s[0]);
if (lineID == id) {
// for (int i = 0; i < s.length - 1; i++) {
// System.out.print(s[i] + " ");
// }
// System.out.println(s[s.length - 1]);
System.out.println(line.trim());
}
line = "";
} else {
line += (char) c;
}
}
fileInputStream.close();
}
}