use

inline fun <T : Closeable, R> T.use(block: (T) -> R): R(source)

Ensures a Closeable object has its close() method called at the end of the supplied block.

Throws

any exceptions thrown in the block will propagate through this method.