SampleTextFileWriter

From JavaWIDE

Jump to: navigation, search

01 //start auto-imports
02 //end auto-imports
03 import java.util.*;
04 import java.io.*;
05 import java.net.*;
06 /**
07  * A simple application to read text from a file on the wiki.
08  @author Jam Jenkins
09  */
10 
11 public class SampleTextFileWriter
12 {
13   public static void mainString[] args )
14   {
15     try //the following code may cause an exception if the file does not exist
16     {
17       //open the input stream using the file name
18       File file = new File"SampleOut.txt" );
19       PrintWriter writer = new PrintWriterfile );
20       writer.println"Hello JavaWIDE!" );
21       writer.println"Hello File Output!" );
22       writer.flush();
23       writer.close();
24     }
25     
26     catch IOException e )          //in case the file does not exist, say so
27     {
28       e.printStackTraceSystem.err );
29     }
30   }
31 }


Download/View SampleTextFileWriter.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter