AutoClosable
interface esures that a resource is closed when it is no longer
required. AutoClosable interface has one method in it. AutoClosable
interface exist from java 1.7 onwards.
void
close() throws Exception
closes
the resource, when it is no longer required. This method executes
automatically, for the resources maintained by try with resource
statement. This method throws an exception if this resource cannot be
closed
Some
of the classes implementing the AutClosable interface are
FileInputStream,
FileLock, FileOutputStream, FileReader, FileSystem, FileWriter,
FilterInputStream, FilterOutputStream etc.,
try with resource statement Suppressed Exceptions Home
No comments:
Post a Comment