com.isti.util
Class TimestampOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended bycom.isti.util.TimestampOutputStream

public class TimestampOutputStream
extends java.io.FilterOutputStream

Class TimestampOutputStream is an output stream filter that adds a timestamp of the current time in front of each line.


Field Summary
protected  java.text.DateFormat dateFormatObj
           
protected static char NEWLINE_CHAR
           
protected  boolean newlineFlag
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
TimestampOutputStream(java.io.OutputStream streamObj)
          Creates a timestamp output stream.
TimestampOutputStream(java.io.OutputStream streamObj, java.lang.String dateFormatStr)
          Creates a timestamp output stream.
 
Method Summary
 void setDateFormatPattern(java.lang.String patternStr)
          Sets the pattern string used to generate the timestamps.
 void setDateFormatTimeZone(java.util.TimeZone timeZoneObj)
          Sets the time zone used for the timestamps.
 void write(byte[] data)
          Writes the given data array.
 void write(byte[] data, int start, int len)
          Writes the given section of the given array.
 void write(int ch)
          Writes a character.
 void writeTimestamp()
          Writes a timestamp and ": " separator to the output stream.
 
Methods inherited from class java.io.FilterOutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEWLINE_CHAR

protected static final char NEWLINE_CHAR
See Also:
Constant Field Values

newlineFlag

protected boolean newlineFlag

dateFormatObj

protected final java.text.DateFormat dateFormatObj
Constructor Detail

TimestampOutputStream

public TimestampOutputStream(java.io.OutputStream streamObj,
                             java.lang.String dateFormatStr)
Creates a timestamp output stream.

Parameters:
streamObj - the output stream to use.
dateFormatStr - the date/time format to use, or null to use the default "MMM dd yyyy HH:mm:ss" format.

TimestampOutputStream

public TimestampOutputStream(java.io.OutputStream streamObj)
Creates a timestamp output stream. Uses the default "MMM dd yyyy HH:mm:ss" format.

Parameters:
streamObj - the output stream to use.
Method Detail

setDateFormatPattern

public void setDateFormatPattern(java.lang.String patternStr)
Sets the pattern string used to generate the timestamps. See the Java help reference for 'SimpleDateFormat' for details on the characters used in the pattern string.

Parameters:
patternStr - the pattern string to apply.

setDateFormatTimeZone

public void setDateFormatTimeZone(java.util.TimeZone timeZoneObj)
Sets the time zone used for the timestamps.

Parameters:
timeZoneObj - the time zone to use.

write

public void write(int ch)
           throws java.io.IOException
Writes a character.

Parameters:
ch - character
Throws:
java.io.IOException

write

public void write(byte[] data)
           throws java.io.IOException
Writes the given data array.

Parameters:
data - data array
Throws:
java.io.IOException

write

public void write(byte[] data,
                  int start,
                  int len)
           throws java.io.IOException
Writes the given section of the given array.

Parameters:
data - data array
start - start index
len - length
Throws:
java.io.IOException

writeTimestamp

public void writeTimestamp()
                    throws java.io.IOException
Writes a timestamp and ": " separator to the output stream.

Throws:
java.io.IOException - if an I/O error occurs.