Question: What am I doing wrong? (Java) I keep on getting a NoSuchElementException public static SortedArrayCollection getBestSellers() throws FileNotFoundException, NoSuchElementException { String title, firstname, lastname, publisher,
What am I doing wrong? (Java) I keep on getting a NoSuchElementException
public static SortedArrayCollection getBestSellers() throws FileNotFoundException, NoSuchElementException { String title, firstname, lastname, publisher, type; int month,day,year; Date date; Book book; SortedArrayCollection list = new SortedArrayCollection<>(); FileReader file = new FileReader("bestsellers.txt"); Scanner readFile = new Scanner(file); readFile.useDelimiter("/, *"); while(readFile.hasNextLine()) { title = readFile.next(); firstname = readFile.next(); lastname = readFile.next(); publisher = readFile.next(); month = readFile.nextInt(); day = readFile.nextInt(); year = readFile.nextInt(); date = new Date(month,day,year); type = readFile.next(); book = new Book(title,firstname,lastname,publisher,year,type); list.add(book); } return list; }