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; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!