org.amicofragile.io
Class TeeOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.amicofragile.io.TeeOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class TeeOutputStream
extends OutputStream

OutputStream which delegates to multiple OutputStreams.

Author:
Pietro Martinelli

Field Summary
private  OutputStream mainStream
          First stream to delegate to.
private  OutputStream[] streams
          Other streams to delegate to.
 
Constructor Summary
TeeOutputStream(OutputStream mainStream, OutputStream... streams)
           
 
Method Summary
 void close()
           
 void flush()
           
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainStream

private final OutputStream mainStream
First stream to delegate to.


streams

private final OutputStream[] streams
Other streams to delegate to.

Constructor Detail

TeeOutputStream

public TeeOutputStream(OutputStream mainStream,
                       OutputStream... streams)
Parameters:
mainStream - First nested stream
streams - Optional nested streams
Method Detail

write

public final void write(int b)
                 throws IOException
Specified by:
write in class OutputStream
Parameters:
b - byte to write
Throws:
IOException - when nested stream throws
See Also:
OutputStream.write(int)

flush

public final void flush()
                 throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException - when nested stream throws
See Also:
OutputStream.flush()

close

public final void close()
                 throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException - when nested stream throws
See Also:
OutputStream.close()


Copyright © 2010. All Rights Reserved.