/** * Adds a single file into the ZipOutputStream with specified entry name. * * @throws IOException */ private void addFileToZip(ZipOutputStream zipOut, UploadedFile file, String name) throws IOException { if (log.isTraceEnabled()) { log.trace(">> addFileToZip(): " + file); } ZipEntry entry = new ZipEntry(name); zipOut.putNextEntry(entry); InputStream in = null; try { in = file.getInputstream(); FileUtils.copyStream(file.getInputstream(), zipOut); zipOut.closeEntry(); } finally { FileUtils.close(in); } // try (InputStream in = file.getInputstream()) { // FileUtils.copyStream(file.getInputstream(), zipOut); // zipOut.closeEntry(); // } if (log.isTraceEnabled()) { log.trace("<< addFileToZip()"); } }