title: Java compress Object or List<double[]>
body: <p>I have an object that has the following structure:</p>
  <pre><code>public class CompressionWrapper implements Serializable {
      private List&lt;double[]&gt; blocks;
      private int height;
      private int width;
  
      constructor, setters and getters...
  }
  </code></pre>
  <p>each double array in <code>blocks</code> is 64 elements long, and I need to compress this into a file. Which library would be the best for this type of compression?</p>
  <p>I have tried using <code>GZIPOutputStream</code> from <code>java.util.zip.GZIPOutputStream</code>, but that actually increases the size of the input file from 490KB to 1011KB.</p>
  <p>My compression method looks like this:</p>
  <pre><code>public static void compress(CompressionWrapper wrapper, String path) throws IOException {
      try {
          File file = new File(path);
          FileOutputStream fileOutputStream = new FileOutputStream(file);
          GZIPOutputStream gzipOutputStream = new GZIPOutputStream(fileOutputStream);
          ObjectOutputStream objectOutputStream = new ObjectOutputStream(gzipOutputStream);
          objectOutputStream.writeObject(wrapper);
          objectOutputStream.flush();
      } catch (Exception e) {
          e.printStackTrace();
          throw e;
      }
  }
  </code></pre>
  <p>EDIT:</p>
  <p><code>$ gzip -l out.bin</code></p>
  <pre><code>         compressed        uncompressed  ratio uncompressed_name
               253314          4293110279 100.0% out.bin
  </code></pre>
  <p>Changing from <code>double</code> to <code>float</code> made a significant difference, should have thought of that myself. Also, upping the compression threshold also made a difference.</p>