nl.knowledgeplaza.util.io
Class TeeWriter

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

public class TeeWriter
extends Writer

This class mirrors output between two writers.

See Also:
Writer

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
TeeWriter(Writer first, Writer second)
          The constructor takes two Writers.
 
Method Summary
 void close()
          Close the underlying Writers.
 void flush()
          Flush both underlying Writers.
 void write(char[] cbuf, int off, int len)
          Write the specified int to each of the underlying Writers.
 
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(Writer first,
                 Writer second)
The constructor takes two Writers. It will mirror any calls to each Writer.

Parameters:
first - The first output stream
second - The second output stream
Method Detail

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Write the specified int to each of the underlying Writers.

Specified by:
write in class Writer
Parameters:
i - The int to write to the underlying streams.
Throws:
IOException - If one of the underlying streams throws it.

flush

public void flush()
           throws IOException
Flush both underlying Writers.

Specified by:
flush in interface Flushable
Specified by:
flush in class Writer
Throws:
IOException - If one of the underlying streams throws it.

close

public void close()
           throws IOException
Close the underlying Writers.

Specified by:
close in interface Closeable
Specified by:
close in class Writer
Throws:
IOException - If one of the underlying streams throws it.


Copyright © 2011 KnowledgePlaza. All Rights Reserved.