SampleTextFileWriter

From JavaWIDE

Jump to: navigation, search

01 import java.io.*;
02 import java.net.*;
03 import java.util.*;
04 /**
05  * All about my application here.
06  @author Jam Jenkins
07  */
08 public class SampleTextFileWriter
09 {
10    public static void main(String[] args)
11    {
12       try{
13          //open the file as a url to avoid violating security
14          URL url=Wiki.getMedia("Sample.txt");
15          url.setDoOutput(true);
16          //use the url to get an input stream
17          PrintWriter writer=new PrintWriter(url.openConnection().getOutputStream());
18          writer.println("Hello");
19          writer.close();
20       }
21       catch(IOException e){
22          e.printStackTrace(System.err);
23       }
24    }
25 }


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