com.jstatcom.io
Class RedirectOutput
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.io.PrintStream
-
- com.jstatcom.io.RedirectOutput
-
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable
public final class RedirectOutput extends java.io.PrintStreamHelper class to redirect stdout and stderr to a log file and/or a receiver component. The redirection also keeps the original streams forSystem.outandSystem.errbut adds an additional stream.Usage Note:
Redirection is initiated by calling thestartmethod. Subsequent calls tostartare allowed to change the file or logging component. Thestopmethod cancels redirection.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static voidstart(RedirectReceiver receiver)Starts redirecting stdout and stderr to a logging component.static voidstart(java.lang.String fileName)Starts redirecting stdout and stderr to a log file.static voidstop()Stops redirecting the output and restored previous settings.voidwrite(byte[] buf, int off, int len)PrintStream overwrite.voidwrite(int b)PrintStream overwrite.
-
-
-
Method Detail
-
start
public static void start(java.lang.String fileName)
Starts redirecting stdout and stderr to a log file.- Parameters:
fileName- the name of the log file- Throws:
java.lang.IllegalArgumentException- iffileName == null
-
start
public static void start(RedirectReceiver receiver)
Starts redirecting stdout and stderr to a logging component.- Parameters:
receiver- the name of the receiving component- Throws:
java.lang.IllegalArgumentException- ifreceiver == null
-
stop
public static void stop()
Stops redirecting the output and restored previous settings.
-
write
public void write(byte[] buf, int off, int len)PrintStream overwrite.- Overrides:
writein classjava.io.PrintStream- Parameters:
buf- byte[]off- intlen- int
-
write
public void write(int b)
PrintStream overwrite.- Overrides:
writein classjava.io.PrintStream- Parameters:
b- int
-
-
DMelt 3.0 © DataMelt by jWork.ORG