Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Java 7 : Try-with-resources - Close resources automatically with AutoCloseable interface

Every time we write code with FileInputStream,

BufferReader

  etc. we need to close those resource explicitly in finally block.

Now from Java 7, there are two interfaces included

Closeable

and

AutoCloseable

with single abstract method

close(),

  which enables implementing class to close resources aromatically after try block.

Lets see how …



This post first appeared on The Geeky Way | Technology Inside Out, please read the originial post: here

Share the post

Java 7 : Try-with-resources - Close resources automatically with AutoCloseable interface

×

Subscribe to The Geeky Way | Technology Inside Out

Get updates delivered right to your inbox!

Thank you for your subscription

×