private byte[] ungzip(byte[] body){
  ByteArrayInputStream bytein=new ByteArrayInputStream(body);
  try (GZIPInputStream gzin=new GZIPInputStream(bytein);ByteArrayOutputStream byteout=new ByteArrayOutputStream()){
    int res=0;
    byte buf[]=new byte[1024];
    while (res >= 0) {
      res=gzin.read(buf,0,buf.length);
      if (res > 0) {
        byteout.write(buf,0,res);
      }
    }
    byte uncompressed[]=byteout.toByteArray();
    return uncompressed;
  }
 catch (  IOException e) {
  }
  return null;
}

private byte [ ] ungzip ( byte [ ] body ) { ByteArrayInputStream bytein = new ByteArrayInputStream ( body ) ; try ( GZIPInputStream gzin = new GZIPInputStream ( bytein ) ; ByteArrayOutputStream byteout = new ByteArrayOutputStream ( ) ) { int res = 0 ; byte buf [ ] = new byte [ 1024 ] ; while ( res >= 0 ) { res = gzin . read ( buf , 0 , buf . length ) ; if ( res > 0 ) { byteout . write ( buf , 0 , res ) ; } } byte uncompressed [ ] = byteout . toByteArray ( ) ; return uncompressed ; } catch ( IOException e ) { } return null ; }
decompresses using gzip algorithm .
