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,751 **** values = null; // for GC } private void dumpBand() throws IOException { assert(optDumpBands); ! PrintStream ps = new PrintStream(getDumpStream(this, ".txt")); String irr = (bandCoding == regularCoding) ? "" : " irregular"; ps.print("# length="+length+ " size="+outputSize()+ irr+" coding="+bandCoding); if (metaCoding != noMetaCoding) { --- 741,751 ---- values = null; // for GC } private void dumpBand() throws IOException { assert(optDumpBands); ! 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,768 **** sb.append(" ").append(metaCoding[i] & 0xFF); } ps.print(" //header: "+sb); } printArrayTo(ps, values, 0, length); ! ps.close(); ! OutputStream ds = getDumpStream(this, ".bnd"); bandCoding.writeArrayTo(ds, values, 0, length); ! ds.close(); } /** Disburse one value. */ protected int getValue() { assert(phase() == DISBURSE_PHASE); --- 755,768 ---- sb.append(" ").append(metaCoding[i] & 0xFF); } ps.print(" //header: "+sb); } printArrayTo(ps, values, 0, length); ! } ! try (OutputStream ds = getDumpStream(this, ".bnd")) { bandCoding.writeArrayTo(ds, values, 0, length); ! } } /** Disburse one value. */ protected int getValue() { assert(phase() == DISBURSE_PHASE);
*** 827,842 **** destroy(); // done with the bits! } private void dumpBand() throws IOException { assert(optDumpBands); ! 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; --- 827,842 ---- destroy(); // done with the bits! } private void dumpBand() throws IOException { assert(optDumpBands); ! try (OutputStream ds = getDumpStream(this, ".bnd")) { if (bytesForDump != null) bytesForDump.writeTo(ds); else bytes.writeTo(ds); ! } } public void readDataFrom(InputStream in) throws IOException { int vex = valuesExpected(); if (vex == 0) return;