Ensure that a closeable object is closed.
Ensure that a closeable object is closed. Note that this function
uses a Scala structural type, rather than a java.io.Closeable
,
because there are classes and interfaces (e.g., java.sql.ResultSet
)
that have close()
methods that do not extend or implement
java.io.Closeable
.
Sample use:
withCloseable(new java.io.FileInputStream("/path/to/file")) { in => ... }
The closeable object is not passed into the block, because its type is useless to the block.
the object that implements Closeable
the code block to execute with the Closeable
whatever the block returns
(Since version 1.5.1) Use grizzled.io.withCloseable
Some utility methods.