|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.Writer | +--java.io.BufferedWriter | +--com.javaranch.common.TextFileOut
A convenience class for writing text files.
Example usage of TextFileOut:
String[] s; // fill array with lovely prose TextFileOut f = new TextFileOut( "file.txt" ); for( int i = 0 ; i < s.length ; i++ ) { f.println( s[ i ] ); } f.close();
- - - - - - - - - - - - - - - - -
Copyright (c) 1998-2004 Paul Wheaton
You are welcome to do whatever you want to with this source file provided that you maintain this comment fragment (between the dashed lines). Modify it, change the package name, change the class name ... personal or business use ... sell it, share it ... add a copyright for the portions you add ...
My goal in giving this away and maintaining the copyright is to hopefully direct developers back to JavaRanch.
The original source can be found at JavaRanch
- - - - - - - - - - - - - - - - -
Field Summary |
Fields inherited from class java.io.Writer |
lock |
Constructor Summary | |
TextFileOut(java.lang.String filename)
Create a new TextFileOut object that will start writing at the beginning of the file. |
|
TextFileOut(java.lang.String filename,
boolean append)
Same as the other constructor only this will open the file for appending. |
Method Summary | |
void |
print(java.lang.String s)
Send a line of text to the file. |
void |
println()
Send a newline to the file. |
void |
println(java.lang.String s)
Send a line of text to the file with a trailing new line appropriate for the o/s. |
void |
writeLine(java.lang.String s)
Send a line of text to the file with a trailing new line appropriate for the o/s. |
Methods inherited from class java.io.BufferedWriter |
close, flush, newLine, write, write, write |
Methods inherited from class java.io.Writer |
write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TextFileOut(java.lang.String filename) throws java.io.IOException
public TextFileOut(java.lang.String filename, boolean append) throws java.io.IOException
filename
- The name of the file to open. append
- Pass in "true" to append. Method Detail |
public void println(java.lang.String s) throws java.io.IOException
s
- The string to send.
java.io.IOException
public void println() throws java.io.IOException
java.io.IOException
public void writeLine(java.lang.String s) throws java.io.IOException
s
- The string to send.
java.io.IOException
public void print(java.lang.String s) throws java.io.IOException
Newlines embedded in the string are properly converted. If that is not what you want, call write() instead.
s
- The string to send.
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |