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 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
To handle the FileNotFoundException in the given Java code you can use a trycatch block Heres how yo... View full answer
Get step-by-step solutions from verified subject matter experts
