|
CS 1705 Library | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Writer
java.io.PrintWriter
net.sf.webcat.PrintWriterWithHistory
public class PrintWriterWithHistory
An enhanced version of PrintWriter that provides for a history
recall function and some other features making I/O testing a bit
easier to perform. See the documentation for PrintWriter for
more thorough details on what methods are provided.
| Constructor Summary | |
|---|---|
PrintWriterWithHistory()
Create a new PrintWriter with no destination--useful when you just want to record the history (for testing, for example). |
|
PrintWriterWithHistory(File file)
Creates a new PrintWriter, without automatic line flushing, with the specified file. |
|
PrintWriterWithHistory(File file,
String csn)
Creates a new PrintWriter, without automatic line flushing, with the specified file and charset. |
|
PrintWriterWithHistory(OutputStream out)
Create a new PrintWriter, with automatic line flushing, from an existing OutputStream. |
|
PrintWriterWithHistory(OutputStream out,
boolean autoFlush)
Create a new PrintWriter from an existing OutputStream. |
|
PrintWriterWithHistory(String fileName)
Creates a new PrintWriter, without automatic line flushing, with the specified file name. |
|
PrintWriterWithHistory(String fileName,
String csn)
Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset. |
|
PrintWriterWithHistory(Writer out)
Create a new PrintWriter, without automatic line flushing. |
|
PrintWriterWithHistory(Writer out,
boolean autoFlush)
Create a new PrintWriter. |
|
| Method Summary | |
|---|---|
void |
clearHistory()
Reset this object's history to be empty, just as when the object was first created. |
String |
getHistory()
Retrieve the text history of what has been sent to this PrintWriter. |
StringBuffer |
getHistoryBuffer()
Retrieve the StringBuffer object used to store this object's text history. |
void |
println()
Terminate the current line by writing the line separator string. |
void |
write(char[] buf,
int off,
int len)
Write A Portion of an array of characters. |
void |
write(int c)
Write a single character. |
void |
write(String s,
int off,
int len)
Write a portion of a string. |
| Methods inherited from class java.io.PrintWriter |
|---|
append, append, append, checkError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, write, write |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PrintWriterWithHistory()
System.out instead,
use this:
new PrintWriterWithHistory(System.out);
public PrintWriterWithHistory(Writer out)
out - A character-output stream
public PrintWriterWithHistory(Writer out,
boolean autoFlush)
out - A character-output streamautoFlush - A boolean; if true, the println,
printf, or format methods will
flush the output bufferpublic PrintWriterWithHistory(OutputStream out)
PrintWriter by forcing automatic
line flushing on instead of off, since students most often use it to
pass in something like System.out.
out - An output streamOutputStreamWriter.OutputStreamWriter(java.io.OutputStream)
public PrintWriterWithHistory(OutputStream out,
boolean autoFlush)
out - An output streamautoFlush - A boolean; if true, the println,
printf, or format methods will
flush the output bufferOutputStreamWriter.OutputStreamWriter(java.io.OutputStream)
public PrintWriterWithHistory(String fileName)
throws FileNotFoundException
OutputStreamWriter,
which will encode characters using the default charset for this
instance of the Java virtual machine.
fileName - The name of the file to use as the destination of this writer.
If the file exists then it will be truncated to zero size;
otherwise, a new file will be created. The output will be
written to the file and is buffered.
FileNotFoundException - If the given string does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file
SecurityException - If a security manager is present and checkWrite(fileName) denies write
access to the file
public PrintWriterWithHistory(String fileName,
String csn)
throws FileNotFoundException,
UnsupportedEncodingException
OutputStreamWriter, which will encode characters using the provided
charset.
fileName - The name of the file to use as the destination of this writer.
If the file exists then it will be truncated to zero size;
otherwise, a new file will be created. The output will be
written to the file and is buffered.csn - The name of a supported charset
FileNotFoundException - If the given string does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file
SecurityException - If a security manager is present and checkWrite(fileName) denies write
access to the file
UnsupportedEncodingException - If the named charset is not supported
public PrintWriterWithHistory(File file)
throws FileNotFoundException
OutputStreamWriter,
which will encode characters using the default charset for this
instance of the Java virtual machine.
file - The file to use as the destination of this writer. If the file
exists then it will be truncated to zero size; otherwise, a new
file will be created. The output will be written to the file
and is buffered.
FileNotFoundException - If the given file object does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file
SecurityException - If a security manager is present and checkWrite(file.getPath())
denies write access to the file
public PrintWriterWithHistory(File file,
String csn)
throws FileNotFoundException,
UnsupportedEncodingException
OutputStreamWriter, which will encode characters using the provided
charset.
file - The file to use as the destination of this writer. If the file
exists then it will be truncated to zero size; otherwise, a new
file will be created. The output will be written to the file
and is buffered.csn - The name of a supported charset
FileNotFoundException - If the given file object does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file
SecurityException - If a security manager is present and checkWrite(file.getPath())
denies write access to the file
UnsupportedEncodingException - If the named charset is not supported| Method Detail |
|---|
public String getHistory()
clearHistory() method resets the history to be empty, just
as when the object was first created. Note that newline characters
in the history are always represented by '\n', regardless of what
value the system line.separator property has.
public void clearHistory()
getHistory().
public StringBuffer getHistoryBuffer()
public void write(int c)
write in class PrintWriterc - int specifying a character to be written.
public void write(char[] buf,
int off,
int len)
write in class PrintWriterbuf - Array of charactersoff - Offset from which to start writing characterslen - Number of characters to write
public void write(String s,
int off,
int len)
write in class PrintWriters - A Stringoff - Offset from which to start writing characterslen - Number of characters to writepublic void println()
line.separator, and is not necessarily a single newline
character ('\n').
println in class PrintWriter
|
Last updated: Wed, Apr 1, 2009 12:29 AM EDT | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||