Oracle

com.compoze.util
Class MultiOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.compoze.util.MultiOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.io.Serializable

public class MultiOutputStream
extends java.io.OutputStream
implements java.io.Serializable

This class writes output to this OutputStream synchronously to any number of underlying OutputStreams.

See Also:
Serialized Form

Constructor Summary
MultiOutputStream()
          Constructor.
MultiOutputStream(java.util.Collection outputStreams)
          Constructor.
MultiOutputStream(java.io.OutputStream[] outputStreams)
          Constructor.
 
Method Summary
 void addOutputStream(java.io.OutputStream os)
          Add an output stream to the list output streams that are written to.
 void close()
          Close all underlying output streams.
 void flush()
          Flush all underlying output streams.
 void removeOutputStream(java.io.OutputStream os)
          Remove an output stream from the list of output streams that are written to.
 void write(byte[] bytes)
          Write to all underlying output streams.
 void write(byte[] bytes, int iOffset, int iLength)
          Write to all underlying output streams.
 void write(int i)
          Write to all underlying output streams.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiOutputStream

public MultiOutputStream()
Constructor.


MultiOutputStream

public MultiOutputStream(java.io.OutputStream[] outputStreams)
Constructor.

Parameters:
outputStreams - an array of output stream to write to

MultiOutputStream

public MultiOutputStream(java.util.Collection outputStreams)
Constructor.

Parameters:
outputStreams - a collection of output stream to write to
Method Detail

addOutputStream

public void addOutputStream(java.io.OutputStream os)
Add an output stream to the list output streams that are written to.

Parameters:
os - the output stream to add

removeOutputStream

public void removeOutputStream(java.io.OutputStream os)
Remove an output stream from the list of output streams that are written to.

Parameters:
os - the output stream to add

close

public void close()
           throws java.io.IOException
Close all underlying output streams.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - if an i/o error occurs

flush

public void flush()
           throws java.io.IOException
Flush all underlying output streams.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - if an i/o error occurs

write

public void write(int i)
           throws java.io.IOException
Write to all underlying output streams.

Specified by:
write in class java.io.OutputStream
Parameters:
i - the byte to write
Throws:
java.io.IOException

write

public void write(byte[] bytes)
           throws java.io.IOException
Write to all underlying output streams.

Overrides:
write in class java.io.OutputStream
Parameters:
bytes - the byte array to write
Throws:
java.io.IOException

write

public void write(byte[] bytes,
                  int iOffset,
                  int iLength)
           throws java.io.IOException
Write to all underlying output streams.

Overrides:
write in class java.io.OutputStream
Parameters:
bytes - to byte array to write
iOffset - offset in array
iLength - number of bytes to write
Throws:
java.io.IOException

Oracle

Copyright ©1999-2008 Oracle All rights reserved.