程序包 weka.core
类 Tee
- 所有已实现的接口:
Closeable
,Flushable
,Appendable
,AutoCloseable
,RevisionHandler
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:
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); ...
- 版本:
- $Revision: 5057 $
- 作者:
- FracPete (fracpete at waikato dot ac dot nz)
-
构造器概要
构造器构造器说明Tee()
initializes the object, with a default printstream.Tee
(PrintStream def) initializes the object with the given default printstream, e.g., System.out. -
方法概要
修饰符和类型方法说明void
add
(PrintStream p) adds the given PrintStream to the list of streams, with NO timestamp and NO prefix.void
add
(PrintStream p, boolean timestamp) adds the given PrintStream to the list of streams, with NO prefix.void
add
(PrintStream p, boolean timestamp, 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
checks whether the given PrintStream is already in the list.void
flush()
flushes all the printstreams.get
(int index) returns the specified PrintStream from the list.returns the default printstrean, can be NULL.Returns the revision string.void
print
(boolean x) prints the given boolean to the streams.void
print
(char x) prints the given char to the streams.void
print
(char[] x) prints the given char array to the streams.void
print
(double x) prints the given double to the streams.void
print
(float x) prints the given float to the streams.void
print
(int x) prints the given int to the streams.void
print
(long x) prints the given long to the streams.void
prints the given object to the streams.void
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
(char x) prints the given char to the streams.void
println
(char[] x) prints the given char array to the streams.void
println
(double x) prints the given double to the streams.void
println
(float x) prints the given float to the streams.void
println
(int x) prints the given int to the streams.void
println
(long x) prints the given long to the streams.void
prints the given object to the streams (for Throwables we print the stack trace).void
prints the given string to the streams.remove
(int index) removes the given PrintStream from the list.removes the given PrintStream from the list.int
size()
returns the number of streams currently in the list.toString()
returns only the classname and the number of streams.void
write
(byte[] buf, int off, int len) Writeslen
bytes from the specified byte array starting at offsetoff
to this stream.void
write
(int b) Writes the specified byte to this stream.从类继承的方法 java.io.PrintStream
append, append, append, checkError, close, format, format, printf, printf, write, writeBytes
从类继承的方法 java.io.OutputStream
nullOutputStream
-
构造器详细资料
-
Tee
public Tee()initializes the object, with a default printstream. -
Tee
initializes the object with the given default printstream, e.g., System.out.- 参数:
def
- the default printstream, remains also after calling clear()
-
-
方法详细资料
-
clear
public void clear()removes all streams and places the default printstream, if any, again in the list.- 另请参阅:
-
getDefault
returns the default printstrean, can be NULL.- 返回:
- the default printstream
- 另请参阅:
-
m_Default
-
add
adds the given PrintStream to the list of streams, with NO timestamp and NO prefix.- 参数:
p
- the printstream to add
-
add
adds the given PrintStream to the list of streams, with NO prefix.- 参数:
p
- the printstream to addtimestamp
- whether to use timestamps or not
-
add
adds the given PrintStream to the list of streams.- 参数:
p
- the printstream to addtimestamp
- whether to use timestamps or notprefix
- the prefix to use
-
get
returns the specified PrintStream from the list.- 参数:
index
- the index of the PrintStream to return- 返回:
- the specified PrintStream, or null if invalid index
-
remove
removes the given PrintStream from the list.- 参数:
p
- the PrintStream to remove- 返回:
- returns the removed PrintStream if it could be removed, null otherwise
-
remove
removes the given PrintStream from the list.- 参数:
index
- the index of the PrintStream to remove- 返回:
- returns the removed PrintStream if it could be removed, null otherwise
-
contains
checks whether the given PrintStream is already in the list.- 参数:
p
- the PrintStream to look for- 返回:
- true if the PrintStream is in the list
-
size
public int size()returns the number of streams currently in the list.- 返回:
- the number of streams in the list
-
flush
public void flush()flushes all the printstreams.- 指定者:
flush
在接口中Flushable
- 覆盖:
flush
在类中PrintStream
-
print
public void print(int x) prints the given int to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
print
public void print(long x) prints the given long to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
print
public void print(float x) prints the given float to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
print
public void print(double x) prints the given double to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
print
public void print(boolean x) prints the given boolean to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
print
public void print(char x) prints the given char to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
print
public void print(char[] x) prints the given char array to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
print
prints the given string to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
print
prints the given object to the streams.- 覆盖:
print
在类中PrintStream
- 参数:
x
- the object to print
-
println
public void println()prints a new line to the streams.- 覆盖:
println
在类中PrintStream
-
println
public void println(int x) prints the given int to the streams.- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
println
public void println(long x) prints the given long to the streams.- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
println
public void println(float x) prints the given float to the streams.- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
println
public void println(double x) prints the given double to the streams.- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
println
public void println(boolean x) prints the given boolean to the streams.- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
println
public void println(char x) prints the given char to the streams.- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
println
public void println(char[] x) prints the given char array to the streams.- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
println
prints the given string to the streams.- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
println
prints the given object to the streams (for Throwables we print the stack trace).- 覆盖:
println
在类中PrintStream
- 参数:
x
- the object to print
-
write
public void write(byte[] buf, int off, int len) Writeslen
bytes from the specified byte array starting at offsetoff
to this stream. If automatic flushing is enabled then theflush
method will be invoked.Note that the bytes will be written as given; to write characters that will be translated according to the platform's default character encoding, use the
print(char)
orprintln(char)
methods.- 覆盖:
write
在类中PrintStream
- 参数:
buf
- A byte arrayoff
- Offset from which to start taking byteslen
- Number of bytes to write
-
write
public void write(int b) Writes the specified byte to this stream. If the byte is a newline and automatic flushing is enabled then theflush
method will be invoked.Note that the byte is written as given; to write a character that will be translated according to the platform's default character encoding, use the
print(char)
orprintln(char)
methods.- 覆盖:
write
在类中PrintStream
- 参数:
b
- The byte to be written- 另请参阅:
-
toString
returns only the classname and the number of streams. -
getRevision
Returns the revision string.- 指定者:
getRevision
在接口中RevisionHandler
- 返回:
- the revision
-