Class CloseShieldWriter

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

    public class CloseShieldWriter
    extends ProxyWriter
    Proxy stream 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.

    Since:
    2.7
    • Constructor Summary

      Constructors 
      Constructor Description
      CloseShieldWriter​(java.io.Writer out)
      Creates a proxy that shields the given writer from being closed.
    • Constructor Detail

      • CloseShieldWriter

        public CloseShieldWriter​(java.io.Writer out)
        Creates a proxy that shields the given writer from being closed.
        Parameters:
        out - underlying writer
    • 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 java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class ProxyWriter