Skip to content

Instantly share code, notes, and snippets.

@ejknapp
Created January 19, 2011 21:28
Show Gist options
  • Select an option

  • Save ejknapp/786899 to your computer and use it in GitHub Desktop.

Select an option

Save ejknapp/786899 to your computer and use it in GitHub Desktop.
package java112.labs1;
import java.util.*;
import java.io.*;
/**
* @author Eric Knapp
* class ExceptionsDemo
*
*/
public class ExceptionsDemo {
public void run() {
BufferedReader input = null;
try {
input = new BufferedReader(new FileReader("compile.sh"));
System.out.println("the file was there!");
} catch (FileNotFoundException fileException) {
System.out.println("no file!");
fileException.printStackTrace();
} catch (IOException ioException) {
ioException.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (input != null) {
input.close();
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
public static void main(String[] args) {
ExceptionsDemo demo = new ExceptionsDemo();
demo.run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment