title: read gzip file to byte[] all at once
body: <p>in code</p>
  
  <pre><code>GZIPInputStream gzis= new GZIPInputStream(bais);
  byte[] bBodyUnzipped= new byte[10240];
  gzis.read(bBodyUnzipped);
  </code></pre>
  
  <p>, how can I optimize the disk space usage and not create a big byte[] by knowing the file unzipped length?</p>
  
  <p>According to <a href="https://stackoverflow.com/questions/7317243/gets-the-uncompressed-size-of-this-gzipinputstream">this answer</a> there is not such method.</p>
  
  <p>The idea is to use this byte[] for calling</p>
  
  <pre><code>CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
  String sBodyUnzipped= decoder.decode(ByteBuffer.wrap(bBodyUnzipped)).toString();
  </code></pre>
  
  <p>For this reason I need a bytye[] with all the content and no extra zeroes.</p>