Hi, Every time when you see "must be caught or declared to be thrown" you have two choices: Catch the exception on throw it back to the calling function.
Look here http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileInputStream.html#FileInputStream(java.lang.String) The text: throws FileNotFoundException <http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileNotFoundException.html> in FileInputStream constructor is also from the constructor signature and specifies that this constructor will not be finished (ant not returning a object) if the file cannot be found. First method : CATCHING THE EXCEPTION try{ FileInputStream f1 = new FileInputStream("myProp2.txt"); ...... }catch(FileNotFoundException ex){ System.out.println("File not founded"); System.exit(1); } The second method. THROWING THE EXCEPTION Example: we don't want to catch inside the function testMe, so the "exception" will be thrown from testMe to the calling function, here the main function public static void main(String[] args) { try{ testMe("myProp2.txt"); }catch(FileNotFoundException ex){ System.out.println("File not found"); System.exit(1); } } /** * not catching the exception, so it throws it back to the calling function */ private static void testMe(String str) throws FileNotFoundException{ FileInputStream f1 = new FileInputStream(str); } There is a yellow bulb with an exclamation point just in the line you have the FileInputStream constructor. If you go there with the mouse you will see the error before you compile. Because this is a simple project, you will catch the exception inside the main function. And, as a rule, anytime you use a method or constructor, see if throws exceptions. Anyway the IDE will warn you before you compile the file. Note also that this is a very simple error and you maybe want to enroll to "Java with Passion" first! Happy coding! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en -~----------~----~----~----~------~----~------~--~---