- byte data[] = new byte[BUFFER];
- FileOutputStream fos = new FileOutputStream(destFile);
- BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
- while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
- dest.write(data, 0, currentByte);
+ byte[] data = new byte[BUFFER];
+ try (FileOutputStream fos = new FileOutputStream(destFile);
+ BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) {
+ while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, currentByte);
+ }
+ dest.flush();
+ } catch (IOException e) {
+ LOGGER.error("Failed to write zip contents to {}" + destFile + e);
+ //
+ // PLD should I throw e?
+ //
+ throw e;