Class CloseShieldOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, 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
    • Constructor Detail

      • CloseShieldOutputStream

        @Deprecated
        public CloseShieldOutputStream​(OutputStream outputStream)
        Deprecated.
        Using this constructor prevents IDEs from warning if the underlying output stream is never closed. Use wrap(OutputStream) instead.
        Creates a proxy that shields the given output stream from being closed.
        Parameters:
        outputStream - underlying output stream
    • Method Detail

      • wrap

        public static CloseShieldOutputStream wrap​(OutputStream outputStream)
        Creates a proxy that shields the given output stream from being closed.
        Parameters:
        outputStream - the output stream to wrap
        Returns:
        the created proxy
        Since:
        2.9.0