--- a/jdk/src/share/classes/java/util/jar/JarFile.java Fri Feb 25 12:11:20 2011 -0800
+++ b/jdk/src/share/classes/java/util/jar/JarFile.java Fri Feb 25 02:06:10 2011 -0800
@@ -376,9 +376,9 @@
*/
private byte[] getBytes(ZipEntry ze) throws IOException {
byte[] b = new byte[(int)ze.getSize()];
- DataInputStream is = new DataInputStream(super.getInputStream(ze));
- is.readFully(b, 0, b.length);
- is.close();
+ try (DataInputStream is = new DataInputStream(super.getInputStream(ze))) {
+ is.readFully(b, 0, b.length);
+ }
return b;
}
@@ -480,10 +480,10 @@
JarEntry manEntry = getManEntry();
if (manEntry != null) {
byte[] b = new byte[(int)manEntry.getSize()];
- DataInputStream dis = new DataInputStream(
- super.getInputStream(manEntry));
- dis.readFully(b, 0, b.length);
- dis.close();
+ try (DataInputStream dis = new DataInputStream(
+ super.getInputStream(manEntry))) {
+ dis.readFully(b, 0, b.length);
+ }
int last = b.length - src.length;
int i = 0;