try FineReader in new FineReadernew File myfile txt Systemo

try {FineReader in = new FineReader(new File (\"myfile. txt\")); System.out.println(\"Got the file!\");} catch (FileNotFoundException e) {System.out.println(\"File not found!\"); catch (Exception e) {System.out.println(\"Whoa!\");} finally {System. out .println (\"Finally!\");} What will this code print if myfile.txt does not exist? What will it print if it does?

Solution

1. Output:

File not found!.

Finally!

Since the catch for file not found exception is there,it will give the corresponding output.

2.Output:

Got the file!

Finally!

No exceptions will be thrown. File is found.

 try {FineReader in = new FineReader(new File (\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site