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

org.apache.commons.io.input

## Class CloseShieldInputStream

- java.lang.Object
- - java.io.InputStream
  - - java.io.FilterInputStream
    - - org.apache.commons.io.input.ProxyInputStream
      - - org.apache.commons.io.input.CloseShieldInputStream

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

      public class CloseShieldInputStream
      extends ProxyInputStream

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

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

  Since:
    1.4
  Version:
    $Id: CloseShieldInputStream.java 1415850 2012-11-30 20:51:39Z ggregory $

- - ### Field Summary

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

      `in`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CloseShieldInputStream(java.io.InputStream in)` Creates a proxy that shields the given input stream from being closed.

  - ### Method Summary

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

    - ### Methods inherited from class org.apache.commons.io.input.ProxyInputStream

      `afterRead, available, beforeRead, handleIOException, mark, markSupported, read, read, read, reset, skip`

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

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

- - ### Constructor Detail

    - #### CloseShieldInputStream

          public CloseShieldInputStream(java.io.InputStream in)

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

  - ### Method Detail

    - #### close

          public void close()

      Replaces the underlying input stream with a `ClosedInputStream` sentinel. The original input 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 `ProxyInputStream`

Copyright (c) 2002-2016 Apache Software Foundation