Throwing an exception from main - Java Object Oriented Design

Java examples for Object Oriented Design:Exception

Description

Throwing an exception from main

Demo Code

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class Main {
  public static void main(String[] args) throws FileNotFoundException {
    openFile("C:/test.txt");
  }/*from   w w  w  .  j  av  a2s. c  om*/

  public static void openFile(String name) throws FileNotFoundException {
    FileInputStream f = new FileInputStream(name);
  }
}

Related Tutorials