CloseShieldOutputStream (Commons IO 2.5)
Date: 2016-12-01

org.apache.commons.io.output

## Class CloseShieldOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - java.io.FilterOutputStream
    - - org.apache.commons.io.output.ProxyOutputStream
      - - org.apache.commons.io.output.CloseShieldOutputStream

- All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

      public class CloseShieldOutputStream
      extends ProxyOutputStream

  Proxy stream that prevents the underlying output stream from being closed.

  This class is typically used in cases where an output stream needs to be passed to a component that wants to explicitly close the stream even if other components would still use the stream for output.

  Since:
    1.4
  Version:
    $Id: CloseShieldOutputStream.java 1674710 2015-04-20 00:25:55Z ggregory $

- - ### Field Summary

    - ### Fields inherited from class java.io.FilterOutputStream

      `out`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CloseShieldOutputStream(java.io.OutputStream out)` Creates a proxy that shields the given output stream from being closed.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Replaces the underlying output stream with a `ClosedOutputStream` sentinel.

    - ### Methods inherited from class org.apache.commons.io.output.ProxyOutputStream

      `afterWrite, beforeWrite, flush, handleIOException, write, write, write`

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### CloseShieldOutputStream

          public CloseShieldOutputStream(java.io.OutputStream out)

      Creates a proxy that shields the given output stream from being closed.
      Parameters:
        `out` - underlying output stream

  - ### Method Detail

    - #### close

          public void close()

      Replaces the underlying output stream with a `ClosedOutputStream` sentinel. The original output stream will remain open, but this proxy will appear closed.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `ProxyOutputStream`

Copyright (c) 2002-2016 Apache Software Foundation