java.lang interface AutoCloseable
Closeable extends AutoCloseable, and is specifically dedicated to IO streams.
Implementing AutoCloseable (or Closeable) allows a class to be used as a resource of the try-with-resources construct introduced in Java 7, which allows closing such resources automatically at the end of a block, without having to add a finally block which closes the resource explicitly.
void close() throws Exception
This method is invoked automatically on objects managed by the try-with-resources statement.
While this interface method is declared to throw Exception, the implementer is strongly encouraged to declare concrete implementations of the close method to throw more specific exceptions, or to throw no exception at all if the close operation cannot fail.
Throws: Exception - if this resource cannot be closed.
Example of AutoCloseable