I have tested the programme on my computer and everything seems to work perfectly. On line 22, I also tried printing out a substring in order to leave the id out, but that doesn't seem to work either.
EDIT: I was able to solve the problem. To give a hint to anyone who may face a similar issue, consider this:
The startsWith() method does precisely what the name implies: check whether a String starts with the specified String. While this initially seems to be exactly what we are looking for in this task, consider this: if you were to enter "5" as an id, it would also pick up any String starting with "5", such as "51", "534", and so on.
package com.codegym.task.task18.task1822;
/*
Finding data inside a file
*/
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String filePath = br.readLine();
try (BufferedReader brFile = new BufferedReader(new FileReader(filePath))) {
String idToSeek = String.valueOf(args[0]);
String line = brFile.readLine();
while (line != null) {
if (line.startsWith(idToSeek)) {
System.out.println(line);
}
line = brFile.readLine();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}