use of lzma.streams.LzmaInputStream in project netty by netty.
the class LzmaFrameEncoderTest method decompress.
@Override
protected ByteBuf decompress(ByteBuf compressed, int originalLength) throws Exception {
InputStream is = new ByteBufInputStream(compressed, true);
LzmaInputStream lzmaIs = null;
byte[] decompressed = new byte[originalLength];
try {
lzmaIs = new LzmaInputStream(is, new Decoder());
int remaining = originalLength;
while (remaining > 0) {
int read = lzmaIs.read(decompressed, originalLength - remaining, remaining);
if (read > 0) {
remaining -= read;
} else {
break;
}
}
assertEquals(-1, lzmaIs.read());
} finally {
if (lzmaIs != null) {
lzmaIs.close();
}
// https://github.com/jponge/lzma-java/issues/14
if (is != null) {
is.close();
}
}
return Unpooled.wrappedBuffer(decompressed);
}
Aggregations