java.lang · java.base · since Java 1.7
AutoCloseable
public interface AutoCloseableThe try-with-resources contract: anything with a close() method can be managed declaratively, with suppressed-exception bookkeeping for free.
- Implement it on every resource-owning class you write (EJ 9)
Key methods
void close() throws Exception | Release the resource; called automatically in reverse declaration order. |