title: Creation of single zip containing multiple zips fails for ServletOutputStream
body: <p>I am using commons compress to zip multiple files and send it the client from a Servlet.
  The files could be a combination of any type of files(text, video, audio, archives, images etc). I take the inputStream of file and write to ServletOutputStream using IOUtils.copy(is, os).
  The code usually works fine for any document combination but when there is a request to download files that contain more than 1 zip, I get <code>java.io.IOException: Closed</code>
  As a result, the zip file created is corrupted even though the size of zip is summation of individual filesizes(I am not using compression).</p>
  
  <p>I tried to locally create zip and use <code>FileOutputStream</code> instead of <code>response.getOutputStream()</code> in the constructor of <code>ZipArchiveOutputStream</code> and it <strong>succeeds</strong>.
  So, it looks like the problem exists for <code>ServletOutputStream</code>.</p>
  
  <p>Can anyone suggest any workaround.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>`try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream( response.getOutputStream())) {
          //get fileList
          for(File file : files) {
             addFileToZip(zos, file.getName(), new BufferedInputStream(new FileInputStream(file)));
          }
          zos.close()
      }
  </code></pre>
  
  <p>`</p>
  
  <pre><code>public static void addFileToZip(ZipArchiveOutputStream zipOutputStream, String filename, InputStream inputStream) throws FileNotFoundException {
      if(zipOutputStream != null &amp;&amp; inputStream != null) {
          try {
              zipOutputStream.putArchiveEntry(new ZipArchiveEntry(filename));
              IOUtils.copy(inputStream, zipOutputStream);
              logger.debug("fileAddedToZip :" + filename);
          } catch (IOException e) {
              logger.error("Error in adding file :" + filename, e); 
          } finally {
              try {
                  inputStream.close();
                  zipOutputStream.closeArchiveEntry(); //**Starts to fail here after 1st zip is added**
              } catch (IOException e) {
                  logger.error("Error in closing zip entry :" + filename, e);
              }
          }
      }
  `
  </code></pre>
  
  <p>Here is the exception trace : 
  `</p>
  
  <pre><code>java.io.IOException: Closed
          at org.mortbay.jetty.AbstractGenerator$Output.write(AbstractGenerator.java:627)
          at org.mortbay.jetty.AbstractGenerator$Output.write(AbstractGenerator.java:577)
          at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.writeOut(ZipArchiveOutputStream.java:1287)
          at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.writeOut(ZipArchiveOutputStream.java:1272)
          at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.writeDataDescriptor(ZipArchiveOutputStream.java:997)
          at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.closeArchiveEntry(ZipArchiveOutputStream.java:461)
          at xxx.yyy.zzz.util.ZipUtils.addFileToZip(ZipUtils.java:110)
  </code></pre>
  
  <p>line 110 is <code>zipOutputStream.closeArchiveEntry(); //**Starts to fail here after 1st zip is added**</code></p>
  
  <p>Thanks in advance.</p>