问题
I am new to LZO compression and decompression. I'm trying to use this lzo-java library.
Input Information :
I have one byte array which is in compressed format. This byte array I want to decompress and finally I want decompressed byte array.
NOTE : I don't know the how much size should give to decompress byte array because I don't know exact size of decompressed byte.
I created below code but it is not giving any exception and not even decompressing single byte.
Program :
InputStream stream = new ByteArrayInputStream(src);
int b1 = stream.read();
int b2 = stream.read();
int b3 = stream.read();
int b4 = stream.read();
int dstLength = ((b1 << 24) + (b2 << 16) + (b3 << 8) + b4);// decompressed byte array length not known
LzoAlgorithm algorithm = LzoAlgorithm.LZO1X;
LzoDecompressor decompressor = LzoLibrary.getInstance().newDecompressor(algorithm, LzoConstraint.SAFETY);
byte dst[] = new byte[dstLength];
lzo_uintp lzo = new lzo_uintp(dstLength);
int decompress = decompressor.decompress(src, 0, src.length, dst, 0, lzo);
System.out.println("decompessed : " + decompress);//it is giving me 0
What I'm missed in above code? Any suggestions will be helpful for me!
来源:https://stackoverflow.com/questions/45397397/how-to-decompress-lzo-compressed-byte-array-in-java