/** * Sets the preset dictionary. This should only be called, if needsDictionary() returns true and * it should set the same dictionary, that was used for deflating. The getAdler() function returns * the checksum of the dictionary needed. * * @param buffer the dictionary. * @param off the offset into buffer where the dictionary starts. * @param len the length of the dictionary. * @exception IllegalStateException if no dictionary is needed. * @exception IllegalArgumentException if the dictionary checksum is wrong. * @exception IndexOutOfBoundsException if the off and/or len are wrong. */ public void setDictionary(byte[] buffer, int off, int len) { if (!needsDictionary()) throw new IllegalStateException(); adler.update(buffer, off, len); if ((int) adler.getValue() != readAdler) throw new IllegalArgumentException("Wrong adler checksum"); adler.reset(); outputWindow.copyDict(buffer, off, len); mode = DECODE_BLOCKS; }
/** * Resets the inflater so that a new stream can be decompressed. All pending input and output will * be discarded. */ public void reset() { mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER; totalIn = totalOut = 0; input.reset(); outputWindow.reset(); dynHeader = null; litlenTree = null; distTree = null; isLastBlock = false; adler.reset(); }