/Users/lyon/j4p/src/bookExamples/ch17Writers/HelloWriter.java

1    package bookExamples.ch17Writers; 
2     
3    import futils.Futil; 
4    import futils.WriterUtil; 
5     
6    import java.io.File; 
7    import java.io.FileWriter; 
8    import java.io.IOException; 
9     
10   /** 
11    * DocJava, Inc. 
12    * http://www.docjava.com 
13    * Programmer: dlyon 
14    * Date: Sep 22, 2004 
15    * Time: 7:40:42 PM 
16    */ 
17   public class HelloWriter { 
18       public static void main(String[] args) { 
19           try { 
20               writerExample2(); 
21           } catch (IOException e) { 
22               e.printStackTrace(); 
23           } 
24    
25       } 
26    
27       private static void writerExample2() throws IOException { 
28           File f = Futil.getWriteFile("enter an output file"); 
29           FileWriter fw = new FileWriter(f); 
30           fw.write("This is a test"); 
31           fw.close(); 
32       } 
33    
34       private static void writerExample1() { 
35           StringBuffer sb = new StringBuffer(); 
36           for (int i=0; i < 100; i++) 
37               sb.append("i="+i+"\f\r\n"); 
38           WriterUtil.writeString(sb + "\nwake up randeep!"); 
39       } 
40   } 
41