previous | start | next

## Catching Exceptions

-     try
      {
       code that might throw an IOException
      }
      catch (IOException exception)
      {
       take corrective action
      }

- Corrective action can be:
  - Notify user of error and offer to read another file
  - Log error in error report file
  - In student programs: print stack trace and exit

        exception.printStackTrace();
        System.exit(1);

previous | start | next