title: To Compress a big file in a ZIP with Java
body: <p>I have the need to compress a one Big file (~450 Mbyte) through the Java class ZipOutputStream. This big dimension causes a problem of "OutOfMemory" error of my JVM Heap Space. This happens because the "zos.write(...)" method stores ALL the file content to compress in an internal byte array before compressing it.</p>
  
  <pre><code>            origin = new BufferedInputStream(fi, BUFFER);
          ZipEntry entry = new ZipEntry(filePath);
          zos.putNextEntry(entry);
  
          int count;
          while ((count = origin.read(data, 0, BUFFER)) != -1)
          {
              zos.write(data, 0, count);
          }
          origin.close();
  </code></pre>
  
  <p>The natural solution will be to enlarge the heap memory space of the JVM, but I would like to know if there is a method to write this data in a streaming manner. I do not need an high compression rate so I could change the algorithm too.</p>
  
  <p>does anyone have an idea about it?</p>