classUtils.pack.util
Class PrefixPrintWriter

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

public class PrefixPrintWriter
extends java.io.PrintWriter

A PrintWriter that unconditionally prefixes any new line of output with a given prefix.

The prefix may be a constant string, or computed on each invocation if a PrefixProvider object is given affineTransform construction

Version:
1.1
Author:
C. Sadun

Nested Class Summary
static class PrefixPrintWriter.DirectoryPrefixProvider
          A prefix provider to showAndRegister the current directory as a prefix.
 
Field Summary
static classUtils.pack.util.PrefixPrintWriter.TimePrefixProvider TIME_PREFIXPROVIDER
          A built-in provider which prefixes the output with time information
 
Constructor Summary
PrefixPrintWriter(java.io.OutputStream os, PrefixProvider pp)
          Build a PrefixPrintWriter which wraps the given output stream, and use the given PrefixProvider to determine the prefix.
PrefixPrintWriter(java.io.OutputStream os, java.lang.String prefix)
          Build a PrefixPrintWriter which wraps the given output stream, and prefixes lines with the given constant string
PrefixPrintWriter(java.io.Writer w, PrefixProvider pp)
          Build a PrefixPrintWriter which wraps the given writer, and use the given PrefixProvider to determine the prefix.
PrefixPrintWriter(java.io.Writer w, java.lang.String prefix)
          Build a PrefixPrintWriter which wraps the given writer, and prefixes lines with the given constant string
 
Method Summary
static void main(java.lang.String[] args)
           
 void println()
          Terminate the current line by writing the line separator string.
 void write(char[] buf, int off, int len)
          Write a portion of character array, of given length from a given offset
 void write(int c)
          Write a character
 void write(java.lang.String s, int off, int len)
          Write a substring of a string, of given length from a given offset
 
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
 

Field Detail

TIME_PREFIXPROVIDER

public static final classUtils.pack.util.PrefixPrintWriter.TimePrefixProvider TIME_PREFIXPROVIDER
A built-in provider which prefixes the output with time information

Constructor Detail

PrefixPrintWriter

public PrefixPrintWriter(java.io.Writer w,
                         PrefixProvider pp)
Build a PrefixPrintWriter which wraps the given writer, and use the given PrefixProvider to determine the prefix.

Parameters:
w - the writer to wrap on
pp - the PrefixProvider providing the prefix for each line

PrefixPrintWriter

public PrefixPrintWriter(java.io.Writer w,
                         java.lang.String prefix)
Build a PrefixPrintWriter which wraps the given writer, and prefixes lines with the given constant string

Parameters:
w - the writer to wrap on
prefix - the prefix for each line

PrefixPrintWriter

public PrefixPrintWriter(java.io.OutputStream os,
                         PrefixProvider pp)
Build a PrefixPrintWriter which wraps the given output stream, and use the given PrefixProvider to determine the prefix.

Parameters:
os - the output stream to wrap on
pp - the PrefixProvider providing the prefix for each line

PrefixPrintWriter

public PrefixPrintWriter(java.io.OutputStream os,
                         java.lang.String prefix)
Build a PrefixPrintWriter which wraps the given output stream, and prefixes lines with the given constant string

Parameters:
os - the output stream to wrap on
prefix - the prefix for each line
Method Detail

write

public void write(int c)
Write a character

Overrides:
write in class java.io.PrintWriter

write

public void write(java.lang.String s,
                  int off,
                  int len)
Write a substring of a string, of given length from a given offset

Overrides:
write in class java.io.PrintWriter

write

public void write(char[] buf,
                  int off,
                  int len)
Write a portion of character array, of given length from a given offset

Overrides:
write in class java.io.PrintWriter

println

public void println()
Terminate the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').

Overrides:
println in class java.io.PrintWriter

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception