org.sadun.util
Class TieWriter

java.lang.Object
  extended byjava.io.Writer
      extended byorg.sadun.util.TieWriter

public class TieWriter
extends java.io.Writer

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

Version:
1.2
Author:
C. Sadun

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
TieWriter(java.io.Writer w1, java.io.Writer w2)
          Build a Writer that ties togheter the two given streams.
 
Method Summary
 void close()
          Close both underlying streams
 void flush()
          Flush both underlying streams
 java.io.Writer getFirstWriter()
          Return the first of the two tied writers
 java.io.Writer getSecondWriter()
          Return the second of the two tied writers
static void main(java.lang.String[] args)
           
 void write(char[] buf, int off, int len)
          Write a byte to the stream, and thus to the two underlying streams.
 
Methods inherited from class java.io.Writer
write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TieWriter

public TieWriter(java.io.Writer w1,
                 java.io.Writer w2)
Build a Writer that ties togheter the two given streams. Every output operation on the Writer will be replicated on both.

Parameters:
w1 - the first stream
w2 - the second stream
Method Detail

write

public void write(char[] buf,
                  int off,
                  int len)
           throws java.io.IOException
Write a byte to the stream, and thus to the two underlying streams.

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.Writer getFirstWriter()
Return the first of the two tied writers

Returns:
the first of the two tied writers

getSecondWriter

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

Returns:
the second of the two tied writers

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception