Question: This Java code can throw a FileNotFoundException. How could you handle this so that the program continues to execute if the exception is thrown?

This Java code can throw a FileNotFoundException. How could you handle this 

This Java code can throw a FileNotFoundException. How could you handle this so that the program continues to execute if the exception is thrown? public void printFileContents (String pathToFile) { String content = getFileContent (pathToFile); // FileNotFoundException could be thrown here System.out.println(content); }

Step by Step Solution

3.46 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To handle the FileNotFoundException in the given Java code you can use a trycatch block Heres how yo... View full answer

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 Programming Questions!