diff options
-rw-r--r-- | ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Zip.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Zip.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Zip.java index 67f58fe..1d757a3 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Zip.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Zip.java @@ -92,15 +92,21 @@ public class Zip { } protected void compressFile(String absolutePath) throws IOException { - compressFileCount++; - byte byteBuf[] = new byte[2048]; - zipOutput.putNextEntry(new ZipEntry(absolutePath.substring(relativeAddrIdx))); - - FileInputStream input = new FileInputStream(absolutePath); - for (int count = 0; (count = input.read(byteBuf, 0, byteBuf.length)) != -1; ) - zipOutput.write(byteBuf, 0, count); - input.close(); - zipOutput.closeEntry(); + try{ + compressFileCount++; + byte byteBuf[] = new byte[2048]; + zipOutput.putNextEntry(new ZipEntry(absolutePath.substring(relativeAddrIdx))); + FileInputStream input = new FileInputStream(absolutePath); + try{ + for (int count = 0; (count = input.read(byteBuf, 0, byteBuf.length)) != -1; ) + zipOutput.write(byteBuf, 0, count); + }finally{ + input.close(); + zipOutput.closeEntry(); + } + }catch(IOException e){ + throw e; + } } public void setCompressLevel(int level) { |