I tried the program and it does what it shall do. I tested it with existing id and with not existing id and even with part of the id. In any case it does what it has to do. Thats why i dont get the validation. Thanks for helping :D
package de.codegym.task.task18.task1822;
import java.io.*;
/*
Daten in einer Datei finden
*/
public class Solution {
public static void main(String[] args) throws IOException{
int id = Integer.parseInt(args[0]);
String ids = id+"";
int idl = ids.length();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String d = reader.readLine();
FileInputStream filo = new FileInputStream(d);
StringBuilder bob = new StringBuilder();
int l = filo.available();
byte[] array = new byte[l];
filo.read(array);
filo.close();
for(int i = 0;i<l;i++){
bob.append((char) array[i]);
}
String s = bob.toString();
boolean con = false;
if(s.contains(ids))con = true;
int start = s.indexOf(ids);
String t = s.substring(start);
String h = t.substring(0,idl+1);
if(!h.contains(" "))con = false;
if(!con)System.out.println("ID gibt es nicht");
else {
String[] ak47 = t.split(" ");
String productName = ak47[1];
double price = Double.parseDouble(ak47[2]);
int quantity = Integer.parseInt(ak47[3]);
System.out.println(id+" "+productName+" "+price+" "+quantity);
}
}
}