Hi,

I got exercise 2.3 to work by some advanced reading, Sang's topic #5 - 
exception handling.
Here's the piece of code I want to share:
>     public static void main(String[] args) {
>         // TODO code application logic here
>         try {
>             FileInputStream propfile =
>                     new FileInputStream("myProperties.txt");
>             Properties p = new Properties(System.getProperties());
>             p.load(propfile);
>             p.setProperty("myKey1", "dan");
>             System.setProperties(p);
>             System.getProperties().list(System.out);
>
>         } catch (FileNotFoundException e) {
>             System.out.println("error - file not found");
>         } catch (SecurityException e) {
>             System.out.println("error - security");
>         } catch (IOException e) {
>             System.out.println("error - IO ");
>         }
>
>     }
>
> }

Dan wrote:
> Hi,
>
> I've been trying to run the homework project to get/set system 
> properties, reading from a text file using the FileInputStream class.  
> I  followed the instructions in the exercise how Java will not throw a 
> FileNotFound exception and yet it still does.
>
> I'm running Netbeans 6.7.1, under Ubuntu 9.10.
>
> In the javadocs, it says that the FileInputStream throws either a 
> FileNotFound exception or a Security exception.  But I don't know yet 
> how to code to catch exceptions :(
>
> Glad for your help, thanks
>
> Dan
>


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to