|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
nl.knowledgeplaza.util.io.TeeOutputStream
public class TeeOutputStream
This class mirrors output between two streams. One sample usage of this is: (with no regard to exceptions);
// setup a log file
FileOutputStream fout = new FileOutputStream("datafile");
// setup a TeeOutputStream for that file and standard out.
TeeOutputStream teeOut = new TeeOutputStream(System.out, fout);
// Wrap the output stream in a PrintStream for added functionality
PrintStream loggedOutput = new PrintStream(teeOut);
// reset standard out to our new tee'd stream set
System.setOut(loggedOutput);
// print to both underlying output streams
System.out.println("Hello there");
OutputStream| Constructor Summary | |
|---|---|
TeeOutputStream(OutputStream first,
OutputStream second)
The constructor takes two OutputStreams. |
|
| Method Summary | |
|---|---|
void |
close()
Close the underlying OutputStreams. |
void |
flush()
Flush both underlying OutputStreams. |
void |
write(int i)
Write the specified int to each of the underlying OutputStreams. |
| Methods inherited from class java.io.OutputStream |
|---|
write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TeeOutputStream(OutputStream first,
OutputStream second)
first - The first output streamsecond - The second output stream| Method Detail |
|---|
public void write(int i)
throws IOException
write in class OutputStreami - The int to write to the underlying streams.
IOException - If one of the underlying streams throws it.
public void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOException - If one of the underlying streams throws it.
public void close()
throws IOException
close in interface Closeableclose in class OutputStreamIOException - If one of the underlying streams throws it.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||