public void testTryWithResourcesStatement() throws FileNotFoundException,
IOException{ FileInputStream in = null; try { in = new FileInputStream("java7.txt"); System.out.println(in.read()); } finally { if (in != null) { in.close(); } } }
Java 7 –
public void testTryWithResourcesStatement() throws FileNotFoundException,
IOException{ try (FileInputStream in = new FileInputStream("java7.txt")) { System.out.println(in.read()); } } 7) The java.nio.file package a. The java.nio.file package and its related package, java.nio.file.attribute, provide comprehensive support for file I/O and for accessing the file system. A zip file system provider is also available in JDK 7. 8)