org.apache.commons.io.output
Class TeeOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by org.apache.commons.io.output.ProxyOutputStream
              extended by org.apache.commons.io.output.TeeOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class TeeOutputStream
extends ProxyOutputStream

Classic splitter of OutputStream. Named after the unix 'tee' command. It allows a stream to be branched off so there are now two streams.

Version:
$Id: TeeOutputStream.java 610010 2008-01-08 14:50:59Z niallp $

Field Summary
protected  OutputStream branch
          the second OutputStream to write to
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
TeeOutputStream(OutputStream out, OutputStream branch)
          Constructs a TeeOutputStream.
 
Method Summary
 void close()
          Closes both streams.
 void flush()
          Flushes both streams.
 void write(byte[] b)
          Write the bytes to both streams.
 void write(byte[] b, int off, int len)
          Write the specified bytes to both streams.
 void write(int b)
          Write a byte to both streams.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

branch

protected OutputStream branch
the second OutputStream to write to

Constructor Detail

TeeOutputStream

public TeeOutputStream(OutputStream out,
                       OutputStream branch)
Constructs a TeeOutputStream.

Parameters:
out - the main OutputStream
branch - the second OutputStream
Method Detail

write

public void write(byte[] b)
           throws IOException
Write the bytes to both streams.

Overrides:
write in class ProxyOutputStream
Parameters:
b - the bytes to write
Throws:
IOException - if an I/O error occurs

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Write the specified bytes to both streams.

Overrides:
write in class ProxyOutputStream
Parameters:
b - the bytes to write
off - The start offset
len - The number of bytes to write
Throws:
IOException - if an I/O error occurs

write

public void write(int b)
           throws IOException
Write a byte to both streams.

Overrides:
write in class ProxyOutputStream
Parameters:
b - the byte to write
Throws:
IOException - if an I/O error occurs

flush

public void flush()
           throws IOException
Flushes both streams.

Specified by:
flush in interface Flushable
Overrides:
flush in class ProxyOutputStream
Throws:
IOException - if an I/O error occurs

close

public void close()
           throws IOException
Closes both streams.

Specified by:
close in interface Closeable
Overrides:
close in class ProxyOutputStream
Throws:
IOException - if an I/O error occurs


Copyright 2002-2008 The Apache Software Foundation. All Rights Reserved.