public class AbortablePrintWriter extends PrintWriter
PrintWriter
that adds the ability to abort creation
and an onClose hook
Experimental API - subject to change.
out
Constructor and Description |
---|
AbortablePrintWriter(PrintWriter pw)
Wrap a
PrintWriter instance. |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort creation of this output.
|
void |
close()
Closes the object and release any system resources it holds.
|
protected void |
onClose(boolean aborted)
Called exactly once when this
PrintWriter is closed or aborted. |
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
public AbortablePrintWriter(PrintWriter pw)
PrintWriter
instance.pw
- RuntimeException
- if there are reflection errors accessing the out
field in pwpublic void abort()
public void close()
java.io.Closeable
Although only the first call has any effect, it is safe to call close
multiple times on the same object. This is more lenient than the
overridden AutoCloseable.close()
, which may be called at most
once.
close
in interface Closeable
close
in interface AutoCloseable
close
in class PrintWriter
protected void onClose(boolean aborted)
PrintWriter
is closed or aborted.aborted
- Copyright © 2016. All rights reserved.