KeepAliveOutputStream (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.util, class: KeepAliveOutputStream

# Class KeepAliveOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.tools.ant.util.KeepAliveOutputStream

All Implemented Interfaces:
  `Closeable, Flushable, AutoCloseable`

public class KeepAliveOutputStream extends 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();
    }

- ## Field Summary

  ### Fields inherited from class FilterOutputStream

  `out`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `KeepAliveOutputStream(OutputStream out)`
  Constructor of KeepAliveOutputStream.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  This method does nothing.
  `static PrintStream`
  `wrapSystemErr()`
  Convenience factory method that returns a non-closing PrintStream around System.err.
  `static PrintStream`
  `wrapSystemOut()`
  Convenience factory method that returns a non-closing PrintStream around System.out.

  ### Methods inherited from class FilterOutputStream

  `flush, write, write, write`

  ### Methods inherited from class OutputStream

  `nullOutputStream`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### KeepAliveOutputStream

    public KeepAliveOutputStream(OutputStream out)
    Constructor of KeepAliveOutputStream.
    Parameters:
      `out` - an OutputStream value, it should be standard output.

- ## Method Details

  - ### close

    public void close() throws IOException
    This method does nothing.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Overrides:
      `close` in class `FilterOutputStream`
    Throws:
      `IOException` - as we are overriding FilterOutputStream.

  - ### wrapSystemOut

    public static PrintStream wrapSystemOut()
    Convenience factory method that returns a non-closing PrintStream around System.out.
    Returns:
      PrintStream
    Since:
      Ant 1.8.0

  - ### wrapSystemErr

    public static PrintStream wrapSystemErr()
    Convenience factory method that returns a non-closing PrintStream around System.err.
    Returns:
      PrintStream
    Since:
      Ant 1.8.0