Created
January 20, 2010 22:31
-
-
Save ejknapp/282360 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Exception demo | |
| package java112.labs1; | |
| import java.io.*; | |
| import java.util.*; | |
| /** | |
| * @author Eric Knapp | |
| * class ExceptionDemo | |
| * TODO: comment | |
| */ | |
| public class ExceptionDemo { | |
| private BufferedReader input; | |
| public void run() { | |
| try { | |
| input = new BufferedReader(new FileReader("sample.txt")); | |
| System.out.println("I'm after the FileReader"); | |
| } catch (java.io.FileNotFoundException fnfe) { | |
| System.out.println("Error"); | |
| fnfe.printStackTrace(); | |
| } catch (java.io.IOException ioe) { | |
| ioe.printStackTrace(); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } finally { | |
| System.out.println("In finally"); | |
| try { | |
| if (input != null){ | |
| input.close(); | |
| } | |
| } catch (java.io.IOException ioe) { | |
| ioe.printStackTrace(); | |
| } | |
| } | |
| System.out.println("I'm at the end"); | |
| } | |
| public static void main(String[] args) { | |
| ExceptionDemo demo = new ExceptionDemo(); | |
| demo.run(); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment