Try With Resources This works just like Try[T] with the following exceptions: - Instead of catching only NonFatal exceptions, catches all Throwables so resources are sure to be released - Accepts a Seq[AutoCloseable] list of resources to close on exit from the Try
Try With Resources This works just like Try[T] with the following exceptions: - Instead of catching only NonFatal exceptions, catches all Throwables so resources are sure to be released - Accepts a Seq[AutoCloseable] list of resources to close on exit from the Try
The
The resources to be closed
Success[T] when successful or Failure[Throwable] when an exceptions is thrown
Try With Resources
This works just like Try[T] with the following exceptions: - Instead of catching only NonFatal exceptions, catches all Throwables so resources are sure to be released - Accepts a Seq[AutoCloseable] list of resources to close on exit from the Try