public static Packet decompress ( final Packet packet ) throws IOException { final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream ( packet . getData ( ) ) ; final GZIPInputStream gzipInputStream = new GZIPInputStream ( byteArrayInputStream ) ; final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ( ) ; // Read from input until everything is inflated final byte buffer [ ] = new byte [ INFLATE_BUFFER_SIZE ] ; int bytesInflated ; while ( ( bytesInflated = gzipInputStream . read ( buffer ) ) >= 0 ) { byteArrayOutputStream . write ( buffer , 0 , bytesInflated ) ; } return new Packet ( packet . getPacketType ( ) , packet . getPacketID ( ) , byteArrayOutputStream . toByteArray ( ) ) ; }
Decompresses given Packet