|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectWriter
PrintWriter
CountingPrintWriter
public class CountingPrintWriter
Prints formatted representations of objects to a text-output stream counting the number of bytes and characters printed.
Methods in this class never throw I/O exceptions. The client may inquire as to whether any errors have occurred by invoking checkError().
| Field Summary |
|---|
| Fields inherited from class PrintWriter |
|---|
out |
| Fields inherited from class Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
CountingPrintWriter(OutputStream out)
Create a new PrintWriter, without automatic line flushing, from an existing OutputStream. |
|
CountingPrintWriter(OutputStream out,
boolean autoFlush)
Create a new PrintWriter from an existing OutputStream. |
|
CountingPrintWriter(Writer out)
Create a new PrintWriter, without automatic line flushing. |
|
CountingPrintWriter(Writer out,
boolean autoFlush)
Create a new PrintWriter, without automatic line flushing. |
|
| Method Summary | |
|---|---|
int |
countBytes(char c)
Returns the number of bytes used to represent a character. |
int |
countBytes(String s)
Returns the number of bytes contained in a string. |
int |
getNumberOfPrintedBytes()
Returns the total number of bytes printed using any of the 'print' or 'println' methods of this CountingPrintBuffer. |
int |
getNumberOfPrintedChars()
Returns the total number of characters printed using any of the 'print' or 'println' methods of this CountingPrintBuffer. |
int |
getNumberOfWrittenBytes()
Returns the total number of bytes printed using any of the 'write' methods of this CountingPrintBuffer. |
void |
print(boolean b)
Print a boolean value. |
void |
print(char c)
Print a character. |
void |
print(char[] s)
Print an array of characters. |
void |
print(double d)
Print a double-precision floating-point number. |
void |
print(float f)
Print a floating-point number. |
void |
print(int i)
Print an integer. |
void |
print(long l)
Print a long integer. |
void |
print(Object obj)
Print an object. |
void |
print(String s)
Print a string. |
void |
println()
Terminate the current line by writing the line separator string. |
void |
println(String x)
Print a String and then terminate the line. |
void |
resetAll()
Resets all the byte and char counters. |
void |
resetPrintedByteCounter()
Resets printedByte counter. |
void |
resetPrintedCharCounter()
Resets printedChar counter. |
void |
resetWrittenByteCounter()
Resets writtenByte counter. |
void |
resetWrittenCharCounter()
Resets writtenChar counter. |
void |
write(char[] buf)
Write an array of characters. |
void |
write(char[] buf,
int off,
int len)
Write a portion of a character array. |
void |
write(String s)
Write a string. |
void |
write(String s,
int off,
int len)
Write a portion of a string. |
| Methods inherited from class PrintWriter |
|---|
append, append, append, checkError, clearError, close, flush, format, format, printf, printf, println, println, println, println, println, println, println, println, setError, write |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CountingPrintWriter(OutputStream out)
out - An output stream
public CountingPrintWriter(OutputStream out,
boolean autoFlush)
out - An output streamautoFlush - A boolean; if true, the println() methods will flush the output bufferpublic CountingPrintWriter(Writer out)
out - a Writer
public CountingPrintWriter(Writer out,
boolean autoFlush)
out - A writerautoFlush - A boolean; if true, the println() methods will flush the output buffer| Method Detail |
|---|
public int countBytes(String s)
s - A Stringpublic int countBytes(char c)
c - A character.public int getNumberOfPrintedBytes()
public int getNumberOfWrittenBytes()
public int getNumberOfPrintedChars()
public void print(String s)
print in class PrintWriterpublic void print(boolean b)
print in class PrintWriterpublic void print(char c)
print in class PrintWriterpublic void print(char[] s)
print in class PrintWriterpublic void print(double d)
print in class PrintWriterpublic void print(float f)
print in class PrintWriterpublic void print(int i)
print in class PrintWriterpublic void resetAll()
public void resetPrintedByteCounter()
public void resetPrintedCharCounter()
public void resetWrittenByteCounter()
public void resetWrittenCharCounter()
public void print(long l)
print in class PrintWriterpublic void print(Object obj)
print in class PrintWriterpublic void println()
When incrementing the byte count of PrintWriter, also accounts for the bytes needed to represent the line separator string.
println in class PrintWriterpublic void println(String x)
println in class PrintWriterpublic void write(char[] buf)
write in class PrintWriter
public void write(char[] buf,
int off,
int len)
write in class PrintWriterbuf - character arrayoff - Offset from which to start writing characterslen - Number of characters to writepublic void write(String s)
write in class PrintWriter
public void write(String s,
int off,
int len)
write in class PrintWriters - string to be printedoff - Offset from which to start writing characterslen - Number of characters to write
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||