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

1    package bookExamples.ch10Exceptions; 
2     
3     
4    import java.io.FileWriter; 
5    import java.io.IOException; 
6     
7    /** 
8     * DocJava, Inc. 
9     * http://www.docjava.com 
10    * Programmer: dlyon 
11    * Date: Sep 8, 2004 
12    * Time: 7:48:53 PM 
13    */ 
14   public class ExceptionExample { 
15       public static void main(String[] args) { 
16           for (float f=0; f < 2 * Math.PI; f=f+.01f) 
17               System.out.println(f/Math.sin(f)); 
18    
19           try { 
20               writeHelloWorld(); 
21           } catch (IOException e) { 
22               e.printStackTrace(); 
23           } 
24    
25    
26       } 
27    
28       private static void writeHelloWorld() throws IOException { 
29           String fileSeparator = utils.SystemUtils.getDirectorySeparator(); 
30           FileWriter fw = new FileWriter("c:"+fileSeparator+"foo.txt"); 
31           fw.write("hello world!"); 
32           fw.close(); 
33       } 
34   } 
35