List of usage examples for java.util.zip Inflater setDictionary
public void setDictionary(ByteBuffer dictionary)
From source file:com.simiacryptus.text.CompressionUtil.java
/** * Decode lz byte [ ]./* w w w . jav a2s . com*/ * * @param data the data * @param dictionary the dictionary * @return the byte [ ] */ public static byte[] decodeLZ(byte[] data, String dictionary) { try { Inflater decompresser = new Inflater(); decompresser.setInput(data, 0, data.length); byte[] result = new byte[data.length * 32]; int resultLength = 0; if (!dictionary.isEmpty()) { resultLength = decompresser.inflate(result); assert (0 == resultLength); if (decompresser.needsDictionary()) { byte[] bytes = dictionary.getBytes("UTF-8"); decompresser.setDictionary(bytes); } } resultLength = decompresser.inflate(result); decompresser.end(); return Arrays.copyOfRange(result, 0, resultLength); } catch (DataFormatException | UnsupportedEncodingException e) { throw new RuntimeException(e); } }