/Users/lyon/j4p/src/bookExamples/ch10Exceptions/ThrowsExample.java

1    package bookExamples.ch10Exceptions; 
2     
3    import java.io.File; 
4    import java.io.FileNotFoundException; 
5    import java.io.FileReader; 
6     
7    public class ThrowsExample { 
8     
9        public static void main(String args[]) { 
10           Float value = Float.valueOf("1.0"); 
11           System.out.println(value); 
12           value = Float.valueOf("blah blah blah"); 
13           System.out.println(value); 
14       } 
15    
16       public static File OpenFile() { 
17           return new File("foo.txt"); 
18       } 
19    
20    
21   } 
22    
23   class FileExample { 
24       public static File openFile() { 
25           return new File("foo.txt"); 
26       } 
27    
28       public static FileReader openFileReader() 
29               throws FileNotFoundException { 
30           return new FileReader(openFile()); 
31       } 
32    
33       public static void main(String args[]) { 
34           try { 
35               System.out.println(openFileReader()); 
36           } catch (FileNotFoundException e) { 
37               e.printStackTrace(); 
38           } 
39       } 
40   } 
41