Class TextFileWrite

java.lang.Object
  |
  +--TextFileWrite

public class TextFileWrite
extends java.lang.Object

This example program reads lines of text from the console and writes them out to a file.


Constructor Summary
TextFileWrite(java.lang.String fn)
          Create a new TextFileWrite object with which to read and write.
 
Method Summary
 void close()
          Close the stream.
static void main(java.lang.String[] arg)
          Test harness for this class.
 void writeOneLine(java.lang.String s)
          Write one line on the output file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextFileWrite

public TextFileWrite(java.lang.String fn)
              throws java.io.IOException
Create a new TextFileWrite object with which to read and write.

Parameters:
fn - the name of the file to write.
Method Detail

writeOneLine

public void writeOneLine(java.lang.String s)
Write one line on the output file.


close

public void close()
           throws java.io.IOException
Close the stream.

Throws:
java.io.IOException - if there is an error closing the file

main

public static void main(java.lang.String[] arg)
                 throws java.io.IOException
Test harness for this class.

Parameters:
arg - arg[0] name of the file to read. Defaults to sampleOut.txt if not specified.
Throws:
java.io.IOException - if there is an error opening or closing the file