Class EDU.gac.max.io.MulticastOutputStream
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class EDU.gac.max.io.MulticastOutputStream

java.lang.Object
   |
   +----java.io.OutputStream
           |
           +----EDU.gac.max.io.MulticastOutputStream

public class MulticastOutputStream
extends OutputStream
The MulticastOutputStream class is used to provide a single stream that encapsulates arbitrarily many constituent streams such that writing to the one MulticastOutputStream effectively writes to all of the constituent streams. A simple example of how this could be used would be to arrange to have messages automatically go both to a log file and to the console.

Efficiency note: the representation chosen for MulticastOutputStream was selected based on the assumption that either the number of constituent streams will be small or the remove method will be infrequently used.

Written 17 Aug 1996 by Max Hailperin <max@gac.edu>


Constructor Index

 o MulticastOutputStream()

Method Index

 o add(OutputStream)
The add method adds another constituent stream to receive all output hencforth sent to the MulticastOutputStream (until the constituent stream is removed).
 o close()
 o flush()
 o remove(OutputStream)
The remove method disconnects one of the constituent streams, so that output to the MulticastOutputStream no longer goes there.
 o write(byte[])
 o write(byte[], int, int)
 o write(int)

Constructors

 o MulticastOutputStream
  public MulticastOutputStream()

Methods

 o add
  public synchronized void add(OutputStream newOut)
The add method adds another constituent stream to receive all output hencforth sent to the MulticastOutputStream (until the constituent stream is removed). This is the only way the MulticastOutputStream comes to do anything useful, because when created there are no constituent streams. It is undefined what will happen if a stream that is already one of the constituent streams is added a second time.
 o remove
  public synchronized void remove(OutputStream oldOut)
The remove method disconnects one of the constituent streams, so that output to the MulticastOutputStream no longer goes there. The removed stream is not closed, however, and thus can still be separately written to or later added back in. It is undefined what happens if the stream is not one of the constituent streams
 o close
  public synchronized void close() throws IOException
Overrides:
close in class OutputStream
 o flush
  public synchronized void flush() throws IOException
Overrides:
flush in class OutputStream
 o write
  public synchronized void write(byte b[]) throws IOException
Overrides:
write in class OutputStream
 o write
  public synchronized void write(byte b[],
                                 int off,
                                 int len) throws IOException
Overrides:
write in class OutputStream
 o write
  public synchronized void write(int b) throws IOException
Overrides:
write in class OutputStream

All Packages  Class Hierarchy  This Package  Previous  Next  Index