āļø Explanatory Question
import java.io.FileReader;
import java.io.IOException;
public class CheckedExample {
public static void main(String[] args) {
try {
FileReader file = new FileReader("non_existing_file.txt");
file.read();
file.close();
} catch (IOException e) {
System.out.println("File not found or cannot be read!");
}
}
}
š Explanation:
The compiler forces you to handle IOException because the file may not exist or may not be readable.