Java examples for Language Basics:try catch finally
Catching Multiple Exceptions with several catch statement
import java.io.FileInputStream; import java.io.IOException; public class Main { public static void main(String[] args) { try {//from w w w.ja v a2 s . co m Class<?> stringClass = Class.forName("java.lang.String"); FileInputStream in = new FileInputStream("myFile.log"); // Can throw IOException in.read(); } catch (IOException e) { System.out.println("There was an IOException " + e); } catch (ClassNotFoundException e) { System.out.println("There was a CLassNotFoundException " + e); } } }