commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From He Shiming <>
Subject [compress] Decompressing bzip2 binary produced by Python bz2?
Date Sun, 25 May 2014 06:43:22 GMT
Dear Community,

I'm porting a Python program to Java. The Python program makes use of bz2 ( to compress the input into a
binary buffer. Its original decompressing code is:

decompressor = bz2.BZ2Decompressor()

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,
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

Best regards,
He Shiming
* <> |
| Toppin'Wiper <>
| MediaMan <>*

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message