|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream tribble.io.MultiOutputStream
public class MultiOutputStream
Multiple output stream. Replicates all output data written to it among one or more output streams.
Data written to this stream are written to all of the underlying output
streams in the order that the streams were added to this object (see the
addOutput()
method).
Note that data is written to all of the output streams even if any of them throw IOExceptions, i.e., the output operation does not stop after the first exception, but continues until all of the streams have been written to. If more than one of the output streams throws an IOException, only the first exception thrown is re-thrown by these methods.
Copyright ©2008 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by
by the United States Department of State as a terrorist, or terrorist
government or agency, to use and distribute this source code provided
that the original copyright notice remains present and unaltered.
Field Summary | |
---|---|
(package private) static java.lang.String |
REV
Revision information. |
static MultiOutputStream |
stdouts
A multiple output stream which writes output to both System.out and System.err. |
Constructor Summary | |
---|---|
MultiOutputStream()
Default constructor. |
|
MultiOutputStream(java.io.OutputStream out)
Constructor. |
|
MultiOutputStream(java.io.OutputStream out1,
java.io.OutputStream out2)
Constructor. |
Method Summary | |
---|---|
int |
addOutput(java.io.OutputStream out)
Add an output stream to this object. |
void |
close()
Close all the output streams of this object. |
void |
flush()
Flush all the output streams of this object. |
java.io.OutputStream |
getOutput(int n)
Retrieve an output stream from this object. |
void |
write(byte[] buf)
Write a set of bytes to the output streams of this object. |
void |
write(byte[] buf,
int off,
int len)
Write a set of bytes to the output streams of this object. |
void |
write(int b)
Write a byte to the output streams of this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
public static final MultiOutputStream stdouts
Constructor Detail |
---|
public MultiOutputStream()
addOutput()
.
public MultiOutputStream(java.io.OutputStream out)
out
- An output stream, to which all the output of this object is written.addOutput()
public MultiOutputStream(java.io.OutputStream out1, java.io.OutputStream out2)
out1
- An output stream, to which all the output of this object is written.out2
- Another output stream, to which all the output of this object is written.addOutput()
Method Detail |
---|
public int addOutput(java.io.OutputStream out)
out
- An output stream, to which all the output of this object is written.
java.lang.NullPointerException
- (unchecked)
Thrown if out is null.getOutput()
public java.io.OutputStream getOutput(int n)
n
- Index of the underlying output stream to retrieve.
The index number is the value returned by a previous call to
addOutput()
.
java.lang.ArrayIndexOutOfBoundsException
- (unchecked)
Thrown if n does not specify a valid output stream index.addOutput()
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
- Thrown if flushing any of the underlying output streams causes an
IOException to be thrown. If this happens, the first exception
thrown is re-thrown by this method after all of the underlying streams are
flushed.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
- Thrown if closing any of the underlying output streams causes an
IOException to be thrown. If this happens, the first exception
thrown is re-thrown by this method after all of the underlying streams are
closed.public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- An output byte.
java.io.IOException
- Thrown if any of the underlying output streams throws this exception.public void write(byte[] buf) throws java.io.IOException
write
(buf, 0, buf.length)
write
in class java.io.OutputStream
buf
- An array of bytes to be written.
java.io.IOException
- Thrown if any of the underlying output streams throws this exception.public void write(byte[] buf, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
buf
- An array of bytes to be written.off
- Index of the first byte in buf to write.len
- Number of bytes in buf to write.
java.io.IOException
- Thrown if any of the underlying output streams throws this exception.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |