|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
de.unibi.techfak.misc.MultiplyOutputStream
public class MultiplyOutputStream
This OutputStream is designed to multiply the output data
and send it to all registered output streams. You can use this class to
write to a file and at the same time to a graphical component, or at the
same time to two files.
Any Exception thrown by a stream is ignored. If no stream is set, the
output is not redirected. But for the purpose of erasing output use
NilOutputStream.
| Field Summary | |
|---|---|
private java.util.Vector |
streams
Holds the streams all output is sent to. |
| Constructor Summary | |
|---|---|
MultiplyOutputStream()
Constructs this class with no stream present to send data to. |
|
MultiplyOutputStream(java.io.OutputStream os)
Registers the first output stream to this class, more can be added using add(OutputStream). |
|
MultiplyOutputStream(java.io.OutputStream os1,
java.io.OutputStream os2)
Registers the first two output streams to this class, more can be added using add(OutputStream). |
|
| Method Summary | |
|---|---|
void |
add(java.io.OutputStream os)
Registers the given OutputStream. |
void |
close()
This call is directed to all registered OutputStreams. |
int |
count()
|
void |
flush()
This call is directed to all registered OutputStreams. |
java.io.OutputStream |
get(int index)
|
boolean |
remove(java.io.OutputStream os)
Removes the given OutputStream from the list of
receivers. |
void |
removeAll()
Removes all receivers. |
void |
write(byte[] b)
This call is directed to all registered OutputStreams. |
void |
write(byte[] b,
int offset,
int len)
This call is directed to all registered OutputStreams. |
void |
write(int b)
The byte is sent to all registered OutputStreams. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.util.Vector streams
| Constructor Detail |
|---|
public MultiplyOutputStream()
add(OutputStream).
public MultiplyOutputStream(java.io.OutputStream os)
add(OutputStream).
os - The first output stream the data is sent to.
public MultiplyOutputStream(java.io.OutputStream os1,
java.io.OutputStream os2)
add(OutputStream).
os1 - The first output stream the data is sent to.os2 - The second output stream the data is sent to.| Method Detail |
|---|
public void close()
OutputStreams.
close in interface java.io.Closeableclose in class java.io.OutputStreampublic void write(int b)
OutputStreams.
write in class java.io.OutputStreamb - The byte to output.
public void write(byte[] b,
int offset,
int len)
OutputStreams.
write in class java.io.OutputStreamb - The byte buffer to be sent to all streams.offset - The index of the first byte in the buffer to sent.len - The number of bytes to sent.public void write(byte[] b)
OutputStreams.
write in class java.io.OutputStreamb - The byte buffer to be sent to all streams.public void flush()
OutputStreams.
flush in interface java.io.Flushableflush in class java.io.OutputStreampublic void add(java.io.OutputStream os)
OutputStream. If it is
null, the method does nothing.
os - The stream to get registered.public boolean remove(java.io.OutputStream os)
OutputStream from the list of
receivers. If it is null or if it could not be
found, the method does nothing else but to return false.
remove(OutputStream) until it returns
false.
os - The stream to get removed from the list of receivers.
true, if the stream could be removed,
false otherwise.public void removeAll()
public int count()
OutputStreams.public java.io.OutputStream get(int index)
OutputStreams with the index.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||