Hello, I was wondering if an expert could help me out with a coding error. I am trying to write a code that reads from a text file but I keep getting an error. I will attach the code and error as seperate files for you to take a look at.

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

Hello, I was wondering if an expert could help me out with a coding error. I am trying to write a code that reads from a text file but I keep getting an error. I will attach the code and error as seperate files for you to take a look at.

1+ import java.util.*;..
3
4 public class ReadRunnersMain {
50
66649
10
11
12
13
14
15
5 167 18 19 2821222324 25 26 27 28 2938312345678394p 1 2 3 4 45 45
20
30
40
41
42
43
44
46}
public static void main (String[] args) {
ArrayList<String> name = new ArrayList<String> ();
ArrayList<Double> distance = new ArrayList<Double>();
ArrayList<Double> time = new ArrayList<Double> ();
int count = 0;
double totalDistance = 0.0, totalTime = 0.0;
try {
}
BufferedReader br = new Buffered Reader (new FileReader("Runners.txt"));
String line;
}
while ((line = br.readLine())!=null) {
String[] record = line.split(" ");
name.add(record [0]);
distance.add(Double.parseDouble (record[1]));
time.add(Double.parseDouble (record[2]));
}
count++;
br.close();
}catch (Exception e) {
e.printStackTrace();
System.out.println("The total number of runs: "+count);
for (Double d: distance)
totalDistance += d;
System.out.println("\nThe total distance of all runs: "+String.format("%.2f", totalDistance)+" miles");
for (Doublet: time)
totalTime += t;
System.out.println("\nThe total time of all runs: "+String.format("%.2f", totalTime)+" minutes");
System.out.println("\nThe names of each runner: ");
for (String n : name)
System.out.println(n);
Transcribed Image Text:1+ import java.util.*;.. 3 4 public class ReadRunnersMain { 50 66649 10 11 12 13 14 15 5 167 18 19 2821222324 25 26 27 28 2938312345678394p 1 2 3 4 45 45 20 30 40 41 42 43 44 46} public static void main (String[] args) { ArrayList<String> name = new ArrayList<String> (); ArrayList<Double> distance = new ArrayList<Double>(); ArrayList<Double> time = new ArrayList<Double> (); int count = 0; double totalDistance = 0.0, totalTime = 0.0; try { } BufferedReader br = new Buffered Reader (new FileReader("Runners.txt")); String line; } while ((line = br.readLine())!=null) { String[] record = line.split(" "); name.add(record [0]); distance.add(Double.parseDouble (record[1])); time.add(Double.parseDouble (record[2])); } count++; br.close(); }catch (Exception e) { e.printStackTrace(); System.out.println("The total number of runs: "+count); for (Double d: distance) totalDistance += d; System.out.println("\nThe total distance of all runs: "+String.format("%.2f", totalDistance)+" miles"); for (Doublet: time) totalTime += t; System.out.println("\nThe total time of all runs: "+String.format("%.2f", totalTime)+" minutes"); System.out.println("\nThe names of each runner: "); for (String n : name) System.out.println(n);
java.io.FileNotFound Exception: Runners.txt (The system cannot find the file specified)
at
(Native Method)
at java.base/java.io. FileInputStream.open (FileInputStream.java:211)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:108)
at java.base/java.io.FileReader.<init>(FileReader.java:60)
at
The total number of runs: 0
The total distance of all runs: 0.00 miles
The total time of all runs: 0.00 minutes
java.base/java.io.FileInputStream.open
ReadRunnersMain.main(ReadRunnersMain.java:13)
The names of each runner:
Transcribed Image Text:java.io.FileNotFound Exception: Runners.txt (The system cannot find the file specified) at (Native Method) at java.base/java.io. FileInputStream.open (FileInputStream.java:211) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:108) at java.base/java.io.FileReader.<init>(FileReader.java:60) at The total number of runs: 0 The total distance of all runs: 0.00 miles The total time of all runs: 0.00 minutes java.base/java.io.FileInputStream.open ReadRunnersMain.main(ReadRunnersMain.java:13) The names of each runner:
Expert Solution
Step 1: Introducing the concept

Hello student


The java.io.FileNotFoundException error is a common issue encountered by Java programmers when attempting to access a file that does not exist in the specified path. This error disrupts the normal flow of the program, leading to unexpected behavior and preventing the intended file operations. Understanding the potential causes of this error is crucial for developers to troubleshoot and resolve it effectively.

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Linux
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.
Similar questions
  • SEE MORE QUESTIONS
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