Package groovy.ui
Class SystemOutputInterceptor
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- groovy.ui.SystemOutputInterceptor
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class SystemOutputInterceptor extends java.io.FilterOutputStream
Intercepts System.out/System.err. Implementation helper for Console.groovy.- Version:
- $Id$
-
-
Constructor Summary
Constructors Constructor Description SystemOutputInterceptor(Closure callback)
ConstructorSystemOutputInterceptor(Closure callback, boolean output)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
start()
Starts intercepting System.out/System.errvoid
stop()
Stops intercepting System.out/System.err, sending output to wherever it was going when this interceptor was created.void
write(byte[] b, int off, int len)
Intercepts output - moret common case of byte[]void
write(int b)
Intercepts output - single characters
-
-
-
Constructor Detail
-
SystemOutputInterceptor
public SystemOutputInterceptor(Closure callback)
Constructor- Parameters:
callback
- accepts a string to be sent to std out and returns a Boolean. If the return value is true, output will be sent to System.out, otherwise it will not.
-
SystemOutputInterceptor
public SystemOutputInterceptor(Closure callback, boolean output)
Constructor- Parameters:
callback
- accepts a string to be sent to std out and returns a Boolean. If the return value is true, output will be sent to System.out/System.err, otherwise it will not.output
- flag that tells whether System.out needs capturing ot System.err
-
-
Method Detail
-
start
public void start()
Starts intercepting System.out/System.err
-
stop
public void stop()
Stops intercepting System.out/System.err, sending output to wherever it was going when this interceptor was created.
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
Intercepts output - moret common case of byte[]- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
Intercepts output - single characters- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
-