Dear Community,
I'm porting a Python program to Java. The Python program makes use of bz2 (
https://docs.python.org/2/library/bz2.html) to compress the input into a
binary buffer. Its original decompressing code is:
decompressor = bz2.BZ2Decompressor()
decompressor.decompress(buffer)
where buffer is produced by file('binary', 'rb').read() . When using the
bzip2 decompressor in Apache Commons:
BZip2CompressorInputStream bis = new BZip2CompressorInputStream(in);
will produce an exception: "Stream is not in the BZip2 format". I checked
the binary buffer, and it does not have a header. It's not a 'bz2' file,
only a buffer segment. According to
http://commons.apache.org/proper/commons-compress/apidocs/src-html/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.html,
the exception is thrown while detecting a 'bz2' file header of 'BZh' +
'1'. On top of that, there appears to be other segment headers it require.
How do I get around this? Can I decompress a buffer directly, and not a bz2
file?
--
Best regards,
He Shiming
*Kaoya.com <http://kaoya.com> | Goals.io
<http://itunes.apple.com/us/app/goals.io-realize-your-dreams/id496228828?ls=1&mt=8>
| Toppin'Wiper <https://itunes.apple.com/app/toppinwiper/id553527232?mt=8>
| MediaMan <http://www.imediaman.com>*