ccs.utils
Class SplitterOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by ccs.utils.SplitterOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class SplitterOutputStream
extends java.io.OutputStream

A SplitterOutputStream copies anything written to it to an arbitrary set of streams.


Constructor Summary
SplitterOutputStream(java.io.OutputStream[] targets)
          Create a splitter which writes to an array of targets.
SplitterOutputStream(java.io.OutputStream q1, java.io.OutputStream q2)
          Creates a splitter which writes to a pair of targets.
 
Method Summary
 void close()
          Close all targets.
 void flush()
          Flush all targets.
 void write(byte[] wad, int off, int len)
          Write the specified subarray of wad to all targets.
 void write(int n)
          write the byte represented by n to all targets.
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitterOutputStream

public SplitterOutputStream(java.io.OutputStream[] targets)
Create a splitter which writes to an array of targets. Do not modify the source array subsequently.


SplitterOutputStream

public SplitterOutputStream(java.io.OutputStream q1,
                            java.io.OutputStream q2)
Creates a splitter which writes to a pair of targets. This is a utility constructor for a common case - use whichever version is more convenient.

Parameters:
q1 - The first stream to write to.
q2 - The second stream to write to.
Method Detail

write

public void write(int n)
           throws java.io.IOException
write the byte represented by n to all targets.

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] wad,
                  int off,
                  int len)
           throws java.io.IOException
Write the specified subarray of wad to all targets.

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Flush all targets.

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

close

public void close()
           throws java.io.IOException
Close all targets.

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