Exemplo n.º 1
0
  /**
   * Adds a single file into the ZipOutputStream with specified entry name.
   *
   * @throws IOException
   */
  private void addFileToZip(ZipOutputStream zipOut, ReshakaUploadedFile file, String name)
      throws IOException {
    if (log.isTraceEnabled()) {
      log.trace(">> addFileToZip(): " + file);
    }

    ZipEntry entry = new ZipEntry(name);
    zipOut.putNextEntry(entry);
    try (InputStream in = file.getInputstream()) {
      FileUtils.copyStream(file.getInputstream(), zipOut);
      zipOut.closeEntry();
    }

    if (log.isTraceEnabled()) {
      log.trace("<< addFileToZip()");
    }
  }