org.apache.commons.io.output

## Class CloseShieldWriter

- java.lang.Object
- - java.io.Writer
  - - java.io.FilterWriter
    - - org.apache.commons.io.output.ProxyWriter
      - - org.apache.commons.io.output.CloseShieldWriter

- All Implemented Interfaces:
    Closeable, Flushable, Appendable, AutoCloseable

      public class CloseShieldWriter
      extends ProxyWriter

  Proxy writer that prevents the underlying writer from being closed.

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

- - ### Field Summary

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

      `out`

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

      `lock`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Replaces the underlying writer with a `ClosedWriter` sentinel.
    `static CloseShieldWriter` | `wrap(Writer writer)` Constructs a proxy that shields the given writer from being closed.

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

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

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

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

- - ### Method Detail

    - #### close

          public void close()

      Replaces the underlying writer with a `ClosedWriter` sentinel. The original writer will remain open, but this proxy will appear closed.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `ProxyWriter`

    - #### wrap

          public static CloseShieldWriter wrap(Writer writer)

      Constructs a proxy that shields the given writer from being closed.
      Parameters:
        `writer` - the writer to wrap
      Returns:
        the created proxy