private static byte[] ungzip(InputStream inputStream, int size) throws IOException {
    try (GZIPInputStream in = new GZIPInputStream(inputStream, size); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
      byte[] buffer = new byte[size];
      int len;
      if ((len = in.read(buffer)) > 0) {
        out.write(buffer, 0, len);
      }
      return out.toByteArray();
    }
  }
Unzip with {@link GZIPInputStream} only the number of bytes set in size parameter
olv-core/src/main/java/pl/otros/logview/api/io/LoadingInfo.java