diff --git a/app/src/full/java/kellinwood/zipio/ZioEntryOutputStream.java b/app/src/full/java/kellinwood/zipio/ZioEntryOutputStream.java index e13332412..2ce56c2f8 100644 --- a/app/src/full/java/kellinwood/zipio/ZioEntryOutputStream.java +++ b/app/src/full/java/kellinwood/zipio/ZioEntryOutputStream.java @@ -28,18 +28,25 @@ public class ZioEntryOutputStream extends OutputStream { int crcValue = 0; OutputStream wrapped; OutputStream downstream; + Deflater deflater; public ZioEntryOutputStream(int compression, OutputStream wrapped) { this.wrapped = wrapped; - if (compression != 0) - downstream = new DeflaterOutputStream(wrapped, new Deflater(Deflater.BEST_COMPRESSION, true)); - else downstream = wrapped; + if (compression != 0) { + deflater = new Deflater(Deflater.BEST_COMPRESSION, true); + downstream = new DeflaterOutputStream(wrapped, deflater); + } else { + downstream = wrapped; + } } public void close() throws IOException { downstream.flush(); downstream.close(); crcValue = (int) crc.getValue(); + if (deflater != null) { + deflater.end(); + } } public int getCRC() {