|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Writer java.io.PrintWriter inua.util.PrintWriter
public class PrintWriter
An extension to Java's Writer object adding lots of convenient
print methods.
Some background. Java has three I/O models: streams (1.0), readers
and writers (1.1), and nio (1.4). What isn't so obvious is which
is prefered (especially given that System.out is a stream). It
turns out that the latter two two, readers and writers for serial
I/O, and nio for block I/O random access are the way to go.
This class extends the prefered
serial interface -
PrintWriter - interface adding mechanisms to simplify the printing
and formatting of decimal, hexadecimal, and string values. It also
adds stdin, stdout, and stderr statics for printing.
You'll also notice that this adopts the 1.5 style of returning the
object rather than the 1.1 style of returning void.
This code makes the simplistic assumption that characters and
padding characters both occupy a single space on the terminal (I
think this is true :-).
Constructor Summary | |
---|---|
PrintWriter(OutputStream out)
Construct from an OutputStream. |
|
PrintWriter(OutputStream out,
boolean flush)
Construct from an OutputStream, possibly enable auto-flush. |
|
PrintWriter(Writer writer)
Construct from a Writer. |
|
PrintWriter(Writer writer,
boolean flush)
Construct from a Writer, possibly enable auto-flush. |
Method Summary | |
---|---|
PrintWriter |
print(int width,
char c)
Print a character in a field at least |WIDTH| characters wide, padding with spaces when necessary. |
PrintWriter |
print(int width,
char padding,
char c)
Print a character in a field at least |WIDTH| characters wide, padding with PADDING when necessary. |
PrintWriter |
print(int width,
char padding,
long l)
Print L in decimal, if L is less than |WIDTH| characters pad to WIDTH with PADDING. |
PrintWriter |
print(int width,
char padding,
String s)
Print a String in a field at least |WIDTH| characters wide, padding with PADDING when necessary. |
PrintWriter |
print(int width,
long l)
Print L in decimal, if L is less than |WIDTH| characters pad to WIDTH with spaces. |
PrintWriter |
print(int width,
String s)
Print a String in a field at least |WIDTH| characters wide, padding with spaces when necessary. |
PrintWriter |
printp(int width,
char padding,
long l)
Print V in decimal, always include a leading sign. |
PrintWriter |
printp(int width,
long l)
Print V in decimal, always include a leading sign. |
PrintWriter |
printp(long l)
Print V in decimal, always include a leading sign. |
PrintWriter |
printx(int width,
char padding,
long l)
Print L as a hexadecimal string, padding out to |WIDTH| with PADDING when necessary. |
PrintWriter |
printx(int width,
long l)
Print L as a hexadecimal string, padding out to |WIDTH| with spaces when necessary. |
PrintWriter |
printx(long l)
Print L as a hexadecimal string. |
Methods inherited from class java.io.PrintWriter |
---|
append, append, append, append, append, append, 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, println, write, write, write, write, write |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PrintWriter(Writer writer)
public PrintWriter(Writer writer, boolean flush)
public PrintWriter(OutputStream out)
public PrintWriter(OutputStream out, boolean flush)
Method Detail |
---|
public final PrintWriter print(int width, char padding, String s)
public final PrintWriter print(int width, String s)
public final PrintWriter print(int width, char padding, char c)
public final PrintWriter print(int width, char c)
public final PrintWriter print(int width, char padding, long l)
public final PrintWriter print(int width, long l)
public final PrintWriter printp(int width, char padding, long l)
public final PrintWriter printp(int width, long l)
public final PrintWriter printp(long l)
public final PrintWriter printx(int width, char padding, long l)
public final PrintWriter printx(int width, long l)
public final PrintWriter printx(long l)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |