019-004-005
Exception Propagation: Delegating Exceptions with throws
Medium
Problem Description
Exception Propagation: Delegating Exceptions with throws
In this problem, you will create a program that simulates file reading using a FileReader class, propagates exceptions to the caller via the throws clause based on the input filename, and displays the result to standard output.
Learning Objective: Understand how to propagate exceptions to the caller using throws clause
Simulate file reading in FileReader class and propagate exceptions to caller.
Input
Line 1: Filename ("valid.txt", "missing.txt", or "error.txt")
Output
Valid.txt: Content: Hello World
Missing.txt: File not found: missing.txt
Error.txt: IO error occurred
Example
Input:
valid.txt
```java
Output:
```java
Content: Hello World
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up