After many changes making to my solution I decided give up to ask for help:)
I displayed found data in original form (the whole line matching criteria) and after cut of id from the beginning in another solution, still without positive effect .
Finally, i am lost how to understand "Display it in the format used in the file" . Please help.
package com.codegym.task.task18.task1822;
/*
Finding data inside a file
ąąą
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream stream = new FileInputStream(reader.readLine());
reader.close();
ArrayList<String> allLines = new ArrayList<>();
StringBuilder line = new StringBuilder();
while (stream.available()>0) {
if (line.length()>0){
allLines.add(line.toString());
line = new StringBuilder();
}
int i = stream.read();
while (stream.available() > 0 && !(Character.isWhitespace(i) && i != ' ')) {
line.append(Character.toChars(i));
i = stream.read();
}
}
stream.close();
int id = 0, idOff = 0;
for (String s : allLines
) {
idOff = s.indexOf(" ") ;
if ( Integer.parseInt(s.substring(0,idOff)) == Integer.parseInt(args[0])){ //(s.substring(0,idOff).equals(args[0])){
//System.out.println(s);
System.out.println(s.substring(idOff+1));
}
}
}
}