org.sadun.util
Class TieOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byorg.sadun.util.TieOutputStream

public class TieOutputStream
extends java.io.OutputStream

An OutputStream which ties output to two underlying streams. Any character written to the stream is replicated on both.

Version:
1.2
Author:
C. Sadun

Constructor Summary
TieOutputStream(java.io.OutputStream os1, java.io.OutputStream os2)
          Build a OutputStream that ties togheter the two given streams.
 
Method Summary
 void close()
          Close both underlying streams
 void flush()
          Flush both underlying streams
 java.io.OutputStream getFirstWriter()
          Return the first of the two tied writers
 java.io.OutputStream getSecondWriter()
          Return the second of the two tied writers
 void write(int b)
          Write a byte to the stream, and thus to the two underlying streams.
 
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
 

Constructor Detail

TieOutputStream

public TieOutputStream(java.io.OutputStream os1,
                       java.io.OutputStream os2)
Build a OutputStream that ties togheter the two given streams. Every output operation on the OutputStream will be replicated on both.

Parameters:
os1 - the first stream
os2 - the second stream
Method Detail

write

public void write(int b)
           throws java.io.IOException
Write a byte to the stream, and thus to the two underlying streams.

Parameters:
b - the byte to write
Throws:
java.io.IOException - if something fails during writing

close

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

Throws:
java.io.IOException - if something fails during closing

flush

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

Throws:
java.io.IOException - if something fails during flushing

getFirstWriter

public java.io.OutputStream getFirstWriter()
Return the first of the two tied writers

Returns:
the first of the two tied writers

getSecondWriter

public java.io.OutputStream getSecondWriter()
Return the second of the two tied writers

Returns:
the second of the two tied writers