Enclose ZipOutputStream handling with try with resources block for
proper stream cleanup.
Change-Id: I2565ef411519f127208a4f966001edf735cb68c0
Signed-off-by: ya107f <ya107f@intl.att.com>
Issue-ID: SDC-886
Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
public static byte[] zipBytes(byte[] input) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ZipOutputStream zos = new ZipOutputStream(baos);
- ZipEntry entry = new ZipEntry("zip");
- entry.setSize(input.length);
- zos.putNextEntry(entry);
- zos.write(input);
- zos.closeEntry();
- zos.close();
+ try (ZipOutputStream zos = new ZipOutputStream(baos)) {
+ ZipEntry entry = new ZipEntry("zip");
+ entry.setSize(input.length);
+ zos.putNextEntry(entry);
+ zos.write(input);
+ zos.closeEntry();
+ zos.close();
+ }
return baos.toByteArray();
}