sdsu.io
Class SplitWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--sdsu.io.SplitWriter

public class SplitWriter
extends java.io.Writer

This class acts like an N way split in a writer stream. N different writers can be connected to the end of a SplitWriter. These N writers are not chained together. What ever is writen on the SplitWriter is copied and written to each of the N writers. The following shows a SplitWriter with three writers.

          |-->----
  ---->---|-->----
          |-->----
 

Version:
1.0 30 December 1997
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Summary
SplitWriter()
          Create an empty SplitWriter.
SplitWriter(java.io.Writer output)
          Create SplitWriter on the given Writer
 
Method Summary
 void add(java.io.OutputStream output)
          Add an outputStream to the end of the SplitWriter.
 void add(java.io.Writer output)
          Add a writer to the end of the SplitWriter.
 void close()
          Close the stream, flushing it first.
 void flush()
          Flush the stream.
 void remove(java.io.Writer output)
          Removes a writer from the SplitWriter.
 void write(char[] charBuffer, int offset, int length)
          Write a portion of an array of characters.
 
Methods inherited from class java.io.Writer
write, write, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitWriter

public SplitWriter(java.io.Writer output)
Create SplitWriter on the given Writer

SplitWriter

public SplitWriter()
Create an empty SplitWriter. Any output on an empty SplitWriter is ignored.
Method Detail

add

public void add(java.io.Writer output)
Add a writer to the end of the SplitWriter.

add

public void add(java.io.OutputStream output)
Add an outputStream to the end of the SplitWriter.

remove

public void remove(java.io.Writer output)
Removes a writer from the SplitWriter.

flush

public void flush()
           throws java.io.IOException
Flush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
Throws:
java.io.IOException - If an I/O error occurs
Overrides:
flush in class java.io.Writer

close

public void close()
           throws java.io.IOException
Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.
Throws:
java.io.IOException - If an I/O error occurs
Overrides:
close in class java.io.Writer

write

public void write(char[] charBuffer,
                  int offset,
                  int length)
           throws java.io.IOException
Write a portion of an array of characters.
Parameters:
charBuffer - Array of characters
offset - Offset from which to start writing characters
length - Number of characters to write
Throws:
java.io.IOException - If an I/O error occurs
Overrides:
write in class java.io.Writer