question: private void nextPacket ( ) throws IOException { int off = 0 ; int remaining = 7 ; do { int count = baseStream . read ( header , off , remaining ) ; if ( count <= 0 ) { throw new EOFException ( "unexpected end of stream, read " + ( 7 - remaining ) + " bytes from " + 7 ) ; } remaining -= count ; off += count ; } while ( remaining > 0 ) ; int compressedLength = ( header [ 0 ] & 0xff ) + ( ( header [ 1 ] & 0xff ) << 8 ) + ( ( header [ 2 ] & 0xff ) << 16 ) ; lastPacketSeq = header [ 3 ] & 0xff ; int decompressedLength = ( header [ 4 ] & 0xff ) + ( ( header [ 5 ] & 0xff ) << 8 ) + ( ( header [ 6 ] & 0xff ) << 16 ) ; if ( decompressedLength != 0 ) { doDecompress = true ; remainingBytes += decompressedLength ; byte [ ] compressedBuffer = new byte [ compressedLength ] ; byte [ ] decompressedBuffer = new byte [ decompressedLength ] ; off = 0 ; remaining = compressedBuffer . length ; do { int count = baseStream . read ( compressedBuffer , off , remaining ) ; if ( count <= 0 ) { throw new EOFException ( "unexpected end of stream, read " + ( 7 - remaining ) + " bytes from " + 7 ) ; } remaining -= count ; off += count ; } while ( remaining > 0 ) ; Inflater inflater = new Inflater ( ) ; inflater . setInput ( compressedBuffer ) ; try { int actualUncompressBytes = inflater . inflate ( decompressedBuffer ) ; if ( actualUncompressBytes != decompressedLength ) { throw new IOException ( "Invalid stream length after decompression " + actualUncompressBytes + ",expected " + decompressedLength ) ; } } catch ( DataFormatException dfe ) { throw new IOException ( dfe ) ; } inflater . end ( ) ; decompressedByteStream = new ByteArrayInputStream ( decompressedBuffer ) ; } else { doDecompress = false ; remainingBytes += compressedLength ; decompressedByteStream = null ; } logger . trace ( "read compress packet seq:" + lastPacketSeq + " length:" + remainingBytes ) ; }
target:  Read stream header. If required, decompress compressed stream.