-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Hi,
Thanks for this amazing repo but I have a quick question: so I am trying to use libdeflate-java to replace Inflater, however in some cases I wasn't able to replicate the results, and it seems to me in some cases, when the compressed data is not well formatted, the libdeflate is more strict about the format and complain about the input data is corrupted.
For example, I am able to use Java's Inflater class to decompress following raw bytes:
byte[] rawBuffer = new byte[]{
4, -64, 81, 10, -62, 48, 12, 6, -32, -69, -4, -49, -11, 2, 121, 84, 111, -96, 62, -115, 49, 106, 90, 88,
-96, 75, -53, -110, 60, -56, -24, -35, -3, 46, -8, 111, 84, 16, 44, -66, -58, -89, 12, -105, -82, -122,
4, -34, -77, 106, 109, 6, 90, 46, 104, 62, 42, 8, 71, 118, -34, -85, 33, 97, -100, -67, 4, -5, 38, -59,
64, 11, -18, -17, -57, -19, -13, 122, 98, 77, -56, -52, 61, -44, 55, 41, 6, -46, 104, 109, -82, -13, 15,
0, 0, -1, -1};
int offset = rawBuffer.length;
Inflater inflater = new Inflater(true);
inflater.setInput(rawBuffer, 0, offset);
ByteBuffer decompressBuffer = ByteBuffer.allocate(4096 * 1024);
decompressBuffer.clear();
try {
int actualLen = 0;
while ((actualLen = inflater.inflate(decompressBuffer.array(),
decompressBuffer.position(),
decompressBuffer.remaining())) > 0) {
decompressBuffer.position(decompressBuffer.position() + actualLen);
}
} catch (DataFormatException e) {
throw new RuntimeException(e);
}
decompressBuffer.flip();
System.out.println(ByteUtil.toString(decompressBuffer));
And this would also fail when nowrap parameter is set to false. So I am wondering is there an equivalent way to use libdeflate to replicate this behavior?
Much appreciate your time and response in advance; and kindly let me know if anything is unclear or needs more explanation.
Metadata
Metadata
Assignees
Labels
No labels