Searched for ""

Contact Us

Please write to us at below address. admin – at – javabeginnerstutorial dot com

Exception Handling – The try-with-resources statement

Generally finally block is used to close all the resources (viz., file, database connection, socket or anything that should be closed after its task is done) to prevent any leaks. Sample code: public class ResourceMgt { public static void main(String[] args) { BufferedReader br = null; try { br = new BufferedReader(new FileReader("C://test.txt")); System.out.println(br.readLine()); }… Continue reading