Return type | Name and parameters |
---|---|
Object
|
withCloseable(Closure action)
Allows this AutoCloseable to be used within the closure, ensuring that it is closed once the closure has been executed and before this method returns. |
Allows this AutoCloseable to be used within the closure, ensuring that it is closed once the closure has been executed and before this method returns.
As with the try-with-resources statement, if multiple exceptions are thrown the exception from the closure will be returned and the exception from closing will be added as a suppressed exception.
action
- the closure taking the AutoCloseable as parameter