org.opends.server.util
Class MultiOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.opends.server.util.MultiOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class MultiOutputStream
extends java.io.OutputStream

This class defines a simple OutputStream object that can be used to write all messages to multiple targets at the same time, much like the UNIX "tee" command. Note that this class will never throw any exceptions


Constructor Summary
MultiOutputStream(java.io.OutputStream... targetStreams)
          Creates a new MultiOutputStream object that will write all messages to all of the target streams.
 
Method Summary
 void close()
          Closes all of the underlying output streams.
 void flush()
          Flushes all of the underlying output streams.
 void write(byte[] b)
          Writes the contents of the provided byte array to all of the underlying output streams.
 void write(byte[] b, int off, int len)
          Writes the specified portion of the provided byte array to all of the underlying output streams.
 void write(int b)
          Writes the specified byte to the set of target 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(java.io.OutputStream... targetStreams)
Creates a new MultiOutputStream object that will write all messages to all of the target streams.

Parameters:
targetStreams - The set of print streams to which all messages should be written. This must not be null, nor may it contain any null elements.
Method Detail

close

public void close()
Closes all of the underlying output streams.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream

flush

public void flush()
Flushes all of the underlying output streams.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream

write

public void write(byte[] b)
Writes the contents of the provided byte array to all of the underlying output streams.

Overrides:
write in class java.io.OutputStream
Parameters:
b - The byte array containing the data to be written.

write

public void write(byte[] b,
                  int off,
                  int len)
Writes the specified portion of the provided byte array to all of the underlying output streams.

Overrides:
write in class java.io.OutputStream
Parameters:
b - The byte array containing the data to be written.
off - The position at which the data to write begins in the array.
len - The number of bytes to b written.

write

public void write(int b)
Writes the specified byte to the set of target output streams.

Specified by:
write in class java.io.OutputStream
Parameters:
b - The byte to be written.