AutoCloseable

An object that may hold resources (such as file or socket handles) until it is closed. The {@link #Close()} method of an {@code AutoCloseable} object is called automatically when exiting a {@code try}-with-resources block for which the object has been declared in the resource specification header. This construction ensures prompt release, avoiding resource exhaustion exceptions and errors that may otherwise occur.

interface AutoCloseable {}

Members

Functions

Close
void Close()

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the {@code try}-with-resources statement.

Meta