ti.io
Class TeeWriter

java.lang.Object
  extended by java.io.Writer
      extended by ti.io.TeeWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class TeeWriter
extends java.io.Writer

This is a writer that can split what is written to it to two different output Writers.

Version:
0.1
Author:
Rob Clark

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
TeeWriter(java.io.Writer w1, java.io.Writer w2)
          Class Constructor.
 
Method Summary
 void close()
          Close both the output writers.
 void flush()
          Flush both the output writers.
 void setPrimaryWriter(java.io.Writer w1)
          Set the primary output writer.
 void setSecondaryWriter(java.io.Writer w2)
          Set the secondary output writer.
 void write(char[] cbuf, int off, int len)
          Write a portion of an array of characters.
 
Methods inherited from class java.io.Writer
append, append, append, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TeeWriter

public TeeWriter(java.io.Writer w1,
                 java.io.Writer w2)
Class Constructor.

Parameters:
w1 - the first of the two output writers
w2 - the second of the two output writers
Method Detail

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws java.io.IOException
Write a portion of an array of characters.

Specified by:
write in class java.io.Writer
Parameters:
cbuf - Array of characters
off - Offset from which to start writing characters
len - Number of characters to write
Throws:
java.io.IOException - If an I/O error occurs

flush

public void flush()
           throws java.io.IOException
Flush both the output writers.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer
Throws:
java.io.IOException - - If an I/O error occurs

close

public void close()
           throws java.io.IOException
Close both the output writers.

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Writer
Throws:
java.io.IOException - - If an I/O error occurs

setPrimaryWriter

public void setPrimaryWriter(java.io.Writer w1)
Set the primary output writer.

Parameters:
w1 - the first of the two output writers

setSecondaryWriter

public void setSecondaryWriter(java.io.Writer w2)
Set the secondary output writer.

Parameters:
w2 - the second of the two output writers