? CloseShieldWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
org.apache.commons.io.output.ProxyWriter
org.apache.commons.io.output.CloseShieldWriter
- ????????:
Closeable
,Flushable
,Appendable
,AutoCloseable
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.
- ???????:
- 2.7
-
????
??????? java.io.FilterWriter
out
-
?????
????????CloseShieldWriter
(Writer writer) ????Using this constructor prevents IDEs from warning if the underlying writer is never closed. -
????
??????????void
close()
Replaces the underlying writer with aClosedWriter
sentinel.static CloseShieldWriter
Creates a proxy that shields the given writer from being closed.??????? org.apache.commons.io.output.ProxyWriter
afterWrite, append, append, append, beforeWrite, flush, handleIOException, write, write, write, write, write
??????? java.io.Writer
nullWriter
-
???????
-
CloseShieldWriter
????Using this constructor prevents IDEs from warning if the underlying writer is never closed. Usewrap(Writer)
instead.Creates a proxy that shields the given writer from being closed.- ??:
writer
- underlying writer
-
-
??????
-
wrap
Creates a proxy that shields the given writer from being closed.- ??:
writer
- the writer to wrap- ??:
- the created proxy
- ???????:
- 2.9.0
-
close
Replaces the underlying writer with aClosedWriter
sentinel. The original writer will remain open, but this proxy will appear closed.- ???:
close
????AutoCloseable
- ???:
close
????Closeable
- ??:
close
???ProxyWriter
-