Question: Code example 9 - 1 import java.io . * ; public class TestFileReader { public static void main ( String [ ] args ) {

Code example 9-1
import java.io.*;
public class TestFileReader {
public static void main(String[] args){
try (BufferedReader in = new BufferedReader(
new FileReader("a.txt"))){
String line = in.readLine();
while (line != null){
String[] v = line.split("::");
String lname = v[0];
String fname = v[1];
String dept = v[2];
System.out.println(fname +""+ lname +", dept "+ dept);
line = in.readLine();
}
} catch (FileNotFoundException e){
System.out.println("File not found.");
} catch (IOException e){
System.out.println("I/O error.");
}
}
}
(Refer to code example 9-1.) What will happen if the file named a.txt doesnt exist?
Group of answer choices
The application will print I/O error. to the console.
The application will print File not found. to the console.
The application will print , dept to the console.
The application will crash and print a stack trace to the console.

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!