How to decompress lzo compressed byte array in java?

南笙酒味 提交于 2019-12-21 06:51:29

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!