protected void readChunkHeader() throws IOException { // Ensure that we have a valid SYNC chunk fillBuffer(fourByteBuffer); if (!Arrays.equals(CompressionOutputStream.SYNC_BYTES, fourByteBuffer)) { throw new IOException("Invalid CompressionInputStream. Expected first 4 bytes to be 'SYNC' but were " + toHex(fourByteBuffer)); } // determine the size of the decompressed buffer fillBuffer(fourByteBuffer); buffer = new byte[toInt(fourByteBuffer)]; // determine the size of the compressed buffer fillBuffer(fourByteBuffer); compressedBuffer = new byte[toInt(fourByteBuffer)]; bufferIndex = buffer.length; // indicate that buffer is empty }
protected void bufferAndDecompress() throws IOException { if (allDataRead) { eos = true; return; } readChunkHeader(); fillBuffer(compressedBuffer); inflater.setInput(compressedBuffer); try { inflater.inflate(buffer); } catch (final DataFormatException e) { throw new IOException(e); } inflater.reset(); bufferIndex = 0; final int moreDataByte = in.read(); if (moreDataByte < 1) { allDataRead = true; } else if (moreDataByte > 1) { throw new IOException("Expected indicator of whether or not more data was to come (-1, 0, or 1) but got " + moreDataByte); } }
protected void readChunkHeader() throws IOException { // Ensure that we have a valid SYNC chunk fillBuffer(fourByteBuffer); if (!Arrays.equals(CompressionOutputStream.SYNC_BYTES, fourByteBuffer)) { throw new IOException("Invalid CompressionInputStream. Expected first 4 bytes to be 'SYNC' but were " + toHex(fourByteBuffer)); } // determine the size of the decompressed buffer fillBuffer(fourByteBuffer); buffer = new byte[toInt(fourByteBuffer)]; // determine the size of the compressed buffer fillBuffer(fourByteBuffer); compressedBuffer = new byte[toInt(fourByteBuffer)]; bufferIndex = buffer.length; // indicate that buffer is empty }
protected void bufferAndDecompress() throws IOException { if (allDataRead) { eos = true; return; } readChunkHeader(); fillBuffer(compressedBuffer); inflater.setInput(compressedBuffer); try { inflater.inflate(buffer); } catch (final DataFormatException e) { throw new IOException(e); } inflater.reset(); bufferIndex = 0; final int moreDataByte = in.read(); if (moreDataByte < 1) { allDataRead = true; } else if (moreDataByte > 1) { throw new IOException("Expected indicator of whether or not more data was to come (-1, 0, or 1) but got " + moreDataByte); } }