I have created this While loop to read lines from a text file. How to I stop the loop after it has found the values?
try
{
BufferedReader file = new BufferedReader(new FileReader("Inventory.txt"));
while (file.ready())
{
String ID = file.readLine();
String Name = file.readLine();
String Price = file.readLine();
if (Value.equals(tf_ID.getText()))
{
System.out.println(Name +" "+ Price);
}
}
}
catch (IOException e)
{
System.out.println("Error");
}
}