blob: df95504d3b989d46543910328ff84b5490f307bd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.io;
import java.util.zip.Inflater;
/**
* @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
*/
public class SlowInflate {
private Inflater inflater = new Inflater();
public byte[] unpack(byte[] compressed, int inflatedLen) {
byte[] decompressed = new byte[inflatedLen];
inflater.reset();
inflater.setInput(compressed);
inflater.finished();
try {
inflater.inflate(decompressed);
} catch (java.util.zip.DataFormatException e) {
throw new RuntimeException("Decompression failure: " + e);
}
return decompressed;
}
}
|