You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Java IO API anticipated that attempting to access a file that does not exist would be a relatively common occurrence, so they created a checked exception to force a developer to deal with it.
publicclassCheckedExceptionEx {
publicvoidisFileNotFound() {
try {
FileInputStreamfile = newFileInputStream("newFile.txt"); // Checked Exception should be handled
} catch (FileNotFoundExceptione) {
e.printStackTrace();
}
}
// Handle below with try-catch block else will get compile time error
publicvoidfileReaderSample() {
// FileReader fileReader = new FileReader("Test.txt");