I have a program that does several different things, one of them being this method to find an item in the file and display the attributes of that file (there are 3) in the row. For some reason, this is only printing out the first three strings in the file, instead of finding and printing the item I search for.
public static void findItem() throws FileNotFoundException {
Scanner kb = new Scanner(System.in);
FileReader reader = new FileReader("read_record.txt");
Scanner fin = new Scanner(reader);
System.out.println("Enter the sku of the dvd you wish to find.");
String dvdSku = kb.next();
while (fin.hasNext()){
String nextString = fin.next();
if (nextString == dvdSku); {
String skuToFind = nextString;
String titleToFind = fin.next();
String lengthToFind = fin.next();
System.out.printf("%-10s %-15s %10s %n",skuToFind,titleToFind,lengthToFind);
break;
}
}
}