I am getting a "Line not found" error in this Java program. Why? What does it mean and how do I resolve the error.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I am getting a "Line not found" error in this Java program. Why? What does it mean and how do I resolve the error.

1® import java.io.*;0
3
4
5 public class Driver2
6 {
private static Student [] students = new Student[100];
private static Scanner kbd = new Scanner (System. in);
8
9
10
@SuppressWarnings("resource")
public static void main(String[] args) throws FileNotFoundException
{
110
12
13
14
FileReader file = new FileReader("students.txt");
Scanner in = new Scanner(file);
15
16
17
18
int i = 0;
19
while (in.hasNextLine())
{
String 11 = in.nextLine();
String 12 = in.nextLine();
String 13 = in.nextLine();
int sem = in.nextInt();
in.nextLine();
20
21
22
23
24
25
26
27
students[i++] = new Student(11, 12, 13, sem);
}
28
29
30
31
runMenu();
32
33
System.out.printf("Program Finished");
R Problems @ Javadoc E Declaration e Console X
<terminated> Driver2 [Java Application] C:\Users\desir\,p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.1.v20211116-1657\jre\
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
at Driver2.main(Driver2.java:26)
Transcribed Image Text:1® import java.io.*;0 3 4 5 public class Driver2 6 { private static Student [] students = new Student[100]; private static Scanner kbd = new Scanner (System. in); 8 9 10 @SuppressWarnings("resource") public static void main(String[] args) throws FileNotFoundException { 110 12 13 14 FileReader file = new FileReader("students.txt"); Scanner in = new Scanner(file); 15 16 17 18 int i = 0; 19 while (in.hasNextLine()) { String 11 = in.nextLine(); String 12 = in.nextLine(); String 13 = in.nextLine(); int sem = in.nextInt(); in.nextLine(); 20 21 22 23 24 25 26 27 students[i++] = new Student(11, 12, 13, sem); } 28 29 30 31 runMenu(); 32 33 System.out.printf("Program Finished"); R Problems @ Javadoc E Declaration e Console X <terminated> Driver2 [Java Application] C:\Users\desir\,p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.1.v20211116-1657\jre\ Exception in thread "main" java.util.NoSuchElementException: No line found at java.base/java.util.Scanner.nextLine(Scanner.java:1651) at Driver2.main(Driver2.java:26)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education