Interface NonAutoCloseable
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
NonAutoCloseableInputStream,NonAutoCloseableOutputStream,NonAutoCloseableReader,NonAutoCloseableWriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A wrapper for AutoCloseable which disables its AutoCloseable.close() method
instead providing doClose() method for explicit closing of this object.
This may come in handy when passing AutoCloseable objects to foreign methods
which may close this object although this should happen later
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Imitates closing this object not actually doing it.voiddoClose()Actually closes this object as if it was done by callingAutoCloseable.close().
-
Method Details
-
close
default void close()Imitates closing this object not actually doing it.- Specified by:
closein interfaceAutoCloseable- API note
- this object should be explicitly called using
doClose()
-
doClose
Actually closes this object as if it was done by callingAutoCloseable.close().- Throws:
Exception- if the resource cannot be closed- See Also:
-