org.apache.tools.ant.utilClass KeepAliveOutputStream
- java.lang.Object
- java.io.OutputStream
- java.io.FilterOutputStream
- org.apache.tools.ant.util.KeepAliveOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
public class KeepAliveOutputStream extends java.io.FilterOutputStream
Class that can be used to wrap System.out and System.err without getting anxious about any client closing the stream.In code-language it means that it is not necessary to do:
if (out != System.out && out != System.err) { out.close(); }
Constructor Summary
Constructors Constructor and Description KeepAliveOutputStream(java.io.OutputStream out)
Constructor of KeepAliveOutputStream.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
close()
This method does nothing.static java.io.PrintStream
wrapSystemErr()
Convenience factory method that returns a non-closing PrintStream around System.err.static java.io.PrintStream
wrapSystemOut()
Convenience factory method that returns a non-closing PrintStream around System.out.
Constructor Detail
KeepAliveOutputStream
public KeepAliveOutputStream(java.io.OutputStream out)Constructor of KeepAliveOutputStream.
- Parameters:
out
- an OutputStream value, it should be standard output.
Method Detail
close
public void close() throws java.io.IOExceptionThis method does nothing.
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- as we are overriding FilterOutputStream.
wrapSystemOut
public static java.io.PrintStream wrapSystemOut()Convenience factory method that returns a non-closing PrintStream around System.out.
- Returns:
- PrintStream
- Since:
- Ant 1.8.0
wrapSystemErr
public static java.io.PrintStream wrapSystemErr()Convenience factory method that returns a non-closing PrintStream around System.err.
- Returns:
- PrintStream
- Since:
- Ant 1.8.0