src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
Print this page
rev 3516 : 7021582: convert jar/zip code and tests to use try-with-resources
Reviewed-by: XXX
@@ -741,11 +741,11 @@
values = null; // for GC
}
private void dumpBand() throws IOException {
assert(optDumpBands);
- PrintStream ps = new PrintStream(getDumpStream(this, ".txt"));
+ try (PrintStream ps = new PrintStream(getDumpStream(this, ".txt"))) {
String irr = (bandCoding == regularCoding) ? "" : " irregular";
ps.print("# length="+length+
" size="+outputSize()+
irr+" coding="+bandCoding);
if (metaCoding != noMetaCoding) {
@@ -755,14 +755,14 @@
sb.append(" ").append(metaCoding[i] & 0xFF);
}
ps.print(" //header: "+sb);
}
printArrayTo(ps, values, 0, length);
- ps.close();
- OutputStream ds = getDumpStream(this, ".bnd");
+ }
+ try (OutputStream ds = getDumpStream(this, ".bnd")) {
bandCoding.writeArrayTo(ds, values, 0, length);
- ds.close();
+ }
}
/** Disburse one value. */
protected int getValue() {
assert(phase() == DISBURSE_PHASE);
@@ -827,16 +827,16 @@
destroy(); // done with the bits!
}
private void dumpBand() throws IOException {
assert(optDumpBands);
- OutputStream ds = getDumpStream(this, ".bnd");
+ try (OutputStream ds = getDumpStream(this, ".bnd")) {
if (bytesForDump != null)
bytesForDump.writeTo(ds);
else
bytes.writeTo(ds);
- ds.close();
+ }
}
public void readDataFrom(InputStream in) throws IOException {
int vex = valuesExpected();
if (vex == 0) return;