Class AbortablePrintWriter

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

    public class AbortablePrintWriter
    extends java.io.PrintWriter
    Wrapper for a PrintWriter that adds the ability to abort creation and an onClose hook

    Experimental API - subject to change.

    • Field Summary

      • Fields inherited from class java.io.PrintWriter

        out
      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      AbortablePrintWriter​(java.io.PrintWriter pw)
      Wrap a PrintWriter instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()
      Abort creation of this output.
      void close()  
      protected void onClose​(boolean aborted)
      Called exactly once when this PrintWriter is closed or aborted.
      • Methods inherited from class java.io.PrintWriter

        append, append, append, checkError, clearError, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write
      • Methods inherited from class java.io.Writer

        nullWriter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbortablePrintWriter

        public AbortablePrintWriter​(java.io.PrintWriter pw)
        Wrap a PrintWriter instance.
        Parameters:
        pw -
        Throws:
        java.lang.RuntimeException - if there are reflection errors accessing the out field in pw
    • Method Detail

      • abort

        public void abort()
        Abort creation of this output.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.PrintWriter
      • onClose

        protected void onClose​(boolean aborted)
        Called exactly once when this PrintWriter is closed or aborted.
        Parameters:
        aborted -