inua.util
Class PrintWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by inua.util.PrintWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class PrintWriter
extends 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

PrintWriter

public PrintWriter(Writer writer)
Construct from a Writer.


PrintWriter

public PrintWriter(Writer writer,
                   boolean flush)
Construct from a Writer, possibly enable auto-flush.


PrintWriter

public PrintWriter(OutputStream out)
Construct from an OutputStream.


PrintWriter

public PrintWriter(OutputStream out,
                   boolean flush)
Construct from an OutputStream, possibly enable auto-flush.

Method Detail

print

public final PrintWriter print(int width,
                               char padding,
                               String s)
Print a String in a field at least |WIDTH| characters wide, padding with PADDING when necessary. If WIDTH is +ve, add padding on the left, otherwize add padding on the right.


print

public final PrintWriter print(int width,
                               String s)
Print a String in a field at least |WIDTH| characters wide, padding with spaces when necessary. If WIDTH is +ve, add padding on the left, otherwize add padding on the right.


print

public final PrintWriter print(int width,
                               char padding,
                               char c)
Print a character in a field at least |WIDTH| characters wide, padding with PADDING when necessary. If WIDTH is +ve, add padding on the left, otherwize add padding on the right.


print

public final PrintWriter print(int width,
                               char c)
Print a character in a field at least |WIDTH| characters wide, padding with spaces when necessary. If WIDTH is +ve, add padding on the left, otherwize add padding on the right.


print

public final PrintWriter print(int width,
                               char padding,
                               long l)
Print L in decimal, if L is less than |WIDTH| characters pad to WIDTH with PADDING.


print

public final PrintWriter print(int width,
                               long l)
Print L in decimal, if L is less than |WIDTH| characters pad to WIDTH with spaces.


printp

public final PrintWriter printp(int width,
                                char padding,
                                long l)
Print V in decimal, always include a leading sign. If L is less than |WIDTH| characters pad with PADDING.


printp

public final PrintWriter printp(int width,
                                long l)
Print V in decimal, always include a leading sign. If L is less than |WIDTH| characters pad with spaces.


printp

public final PrintWriter printp(long l)
Print V in decimal, always include a leading sign.


printx

public final PrintWriter printx(int width,
                                char padding,
                                long l)
Print L as a hexadecimal string, padding out to |WIDTH| with PADDING when necessary.


printx

public final PrintWriter printx(int width,
                                long l)
Print L as a hexadecimal string, padding out to |WIDTH| with spaces when necessary.


printx

public final PrintWriter printx(long l)
Print L as a hexadecimal string.