title: Zipping InputStream, returning InputStream (in memory, no file)
body: <p>I am trying to do compress an InputStream and return an InputStream:</p>
  <pre><code>public InputStream compress (InputStream in){
    // Read &quot;in&quot; and write to ZipOutputStream
    // Convert ZipOutputStream into InputStream and return
  }
  </code></pre>
  <p>I am compressing one file (so I could use GZIP) but will do more in future (so I opted for ZIP). In most of the places:</p>
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/11036280/compress-an-inputstream-with-gzip">Compress an InputStream with gzip</a></p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/7853972/how-can-i-convert-zipinputstream-to-inputstream">How can I convert ZipInputStream to InputStream?</a></p>
  <p>They use toBytesArray() or getBytes() which do not exist (!) -  <a href="http://docs.oracle.com/javase/7/docs/api/java/util/zip/ZipOutputStream.html" rel="noreferrer">ZipOutputStream</a></p>
  </li>
  </ul>
  <p>My problems are:</p>
  <ol>
  <li><p>How do I convert the ZipOutPutStream into InputStream if such methods don't exist?</p>
  </li>
  <li><p>When creating the ZipOutPutStream() there is no default constructor. Should I create a new ZipOutputStrem(new OutputStream() )  ??</p>
  </li>
  </ol>