1.1 --- a/src/share/classes/com/sun/tools/classfile/ClassFile.java Thu Jun 27 09:51:59 2013 +0100 1.2 +++ b/src/share/classes/com/sun/tools/classfile/ClassFile.java Thu Jun 27 09:54:50 2013 +0100 1.3 @@ -26,9 +26,9 @@ 1.4 package com.sun.tools.classfile; 1.5 1.6 import java.io.File; 1.7 -import java.io.FileInputStream; 1.8 import java.io.IOException; 1.9 import java.io.InputStream; 1.10 +import java.nio.file.Files; 1.11 import java.nio.file.Path; 1.12 1.13 import static com.sun.tools.classfile.AccessFlags.*; 1.14 @@ -44,26 +44,24 @@ 1.15 public class ClassFile { 1.16 public static ClassFile read(File file) 1.17 throws IOException, ConstantPoolException { 1.18 - return read(file, new Attribute.Factory()); 1.19 + return read(file.toPath(), new Attribute.Factory()); 1.20 } 1.21 1.22 - public static ClassFile read(Path path) 1.23 + public static ClassFile read(Path input) 1.24 throws IOException, ConstantPoolException { 1.25 - return read(path.toFile(), new Attribute.Factory()); 1.26 + return read(input, new Attribute.Factory()); 1.27 + } 1.28 + 1.29 + public static ClassFile read(Path input, Attribute.Factory attributeFactory) 1.30 + throws IOException, ConstantPoolException { 1.31 + try (InputStream in = Files.newInputStream(input)) { 1.32 + return new ClassFile(in, attributeFactory); 1.33 + } 1.34 } 1.35 1.36 public static ClassFile read(File file, Attribute.Factory attributeFactory) 1.37 throws IOException, ConstantPoolException { 1.38 - FileInputStream in = new FileInputStream(file); 1.39 - try { 1.40 - return new ClassFile(in, attributeFactory); 1.41 - } finally { 1.42 - try { 1.43 - in.close(); 1.44 - } catch (IOException e) { 1.45 - // ignore 1.46 - } 1.47 - } 1.48 + return read(file.toPath(), attributeFactory); 1.49 } 1.50 1.51 public static ClassFile read(InputStream in)