|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
weka.core.Tee
public class Tee
This class pipelines print/println's to several PrintStreams. Useful for
redirecting System.out and System.err to files etc.
E.g., for redirecting stderr/stdout to files with timestamps and:
import java.io.*; import weka.core.Tee; ... // stdout Tee teeOut = new Tee(System.out); teeOut.add(new PrintStream(new FileOutputStream("out.txt")), true); System.setOut(teeOut); // stderr Tee teeErr = new Tee(System.err); teeErr.add(new PrintStream(new FileOutputStream("err.txt")), true); System.setOut(teeErr); ...
Constructor Summary | |
---|---|
Tee()
initializes the object, with a default printstream |
|
Tee(java.io.PrintStream def)
initializes the object with the given default printstream, e.g., System.out. |
Method Summary | |
---|---|
void |
add(java.io.PrintStream p)
adds the given PrintStream to the list of streams, with NO timestamp and NO prefix |
void |
add(java.io.PrintStream p,
boolean timestamp)
adds the given PrintStream to the list of streams, with NO prefix |
void |
add(java.io.PrintStream p,
boolean timestamp,
java.lang.String prefix)
adds the given PrintStream to the list of streams |
void |
clear()
removes all streams and places the default printstream, if any, again in the list |
boolean |
contains(java.io.PrintStream p)
checks whether the given PrintStream is already in the list |
void |
flush()
flushes all the printstreams |
java.io.PrintStream |
get(int index)
returns the specified PrintStream from the list |
java.io.PrintStream |
getDefault()
returns the default printstrean, can be NULL |
java.lang.String |
getRevision()
Returns the revision string. |
void |
print(boolean x)
prints the given boolean to the streams |
void |
print(int x)
prints the given int to the streams |
void |
print(java.lang.Object x)
prints the given object to the streams |
void |
print(java.lang.String x)
prints the given string to the streams |
void |
println()
prints a new line to the streams |
void |
println(boolean x)
prints the given boolean to the streams |
void |
println(int x)
prints the given int to the streams |
void |
println(java.lang.Object x)
prints the given object to the streams (for Throwables we print the stack trace) |
void |
println(java.lang.String x)
prints the given string to the streams |
java.io.PrintStream |
remove(int index)
removes the given PrintStream from the list |
java.io.PrintStream |
remove(java.io.PrintStream p)
removes the given PrintStream from the list |
int |
size()
returns the number of streams currently in the list |
java.lang.String |
toString()
returns only the classname and the number of streams |
Methods inherited from class java.io.PrintStream |
---|
append, append, append, checkError, close, format, format, print, print, print, print, print, printf, printf, println, println, println, println, println, write, write |
Methods inherited from class java.io.FilterOutputStream |
---|
write |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Tee()
public Tee(java.io.PrintStream def)
def
- the default printstream, remains also after calling clear()Method Detail |
---|
public void clear()
getDefault()
public java.io.PrintStream getDefault()
m_Default
public void add(java.io.PrintStream p)
p
- the printstream to addpublic void add(java.io.PrintStream p, boolean timestamp)
p
- the printstream to addtimestamp
- whether to use timestamps or notpublic void add(java.io.PrintStream p, boolean timestamp, java.lang.String prefix)
p
- the printstream to addtimestamp
- whether to use timestamps or notprefix
- the prefix to usepublic java.io.PrintStream get(int index)
index
- the index of the PrintStream to return
public java.io.PrintStream remove(java.io.PrintStream p)
p
- the PrintStream to remove
public java.io.PrintStream remove(int index)
index
- the index of the PrintStream to remove
public boolean contains(java.io.PrintStream p)
p
- the PrintStream to look for
public int size()
public void flush()
flush
in interface java.io.Flushable
flush
in class java.io.PrintStream
public void print(int x)
print
in class java.io.PrintStream
x
- the object to printpublic void print(boolean x)
print
in class java.io.PrintStream
x
- the object to printpublic void print(java.lang.String x)
print
in class java.io.PrintStream
x
- the object to printpublic void print(java.lang.Object x)
print
in class java.io.PrintStream
x
- the object to printpublic void println()
println
in class java.io.PrintStream
public void println(int x)
println
in class java.io.PrintStream
x
- the object to printpublic void println(boolean x)
println
in class java.io.PrintStream
x
- the object to printpublic void println(java.lang.String x)
println
in class java.io.PrintStream
x
- the object to printpublic void println(java.lang.Object x)
println
in class java.io.PrintStream
x
- the object to printpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getRevision()
getRevision
in interface RevisionHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |