{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

CloseableKt

public final class CloseableKt


Summary

Public methods

static final @NonNull R
<T extends Closeable, R extends Object> use(
    @NonNull T receiver,
    @NonNull Function1<@NonNull T, @NonNull R> block
)

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

Public methods

use

public static final @NonNull R <T extends Closeable, R extends Object> use(
    @NonNull T receiver,
    @NonNull Function1<@NonNull T, @NonNull R> block
)

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

Throws
kotlin.Throwable

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