public byte[] bZip2Decompress(byte[] compressedBytes) throws IOException {
byte[] uncompressedBytes = new byte[BUFFER_SIZE];
BZip2CompressorInputStream bZip2Stream = new BZip2CompressorInputStream(new ByteArrayInputStream(compressedBytes));
bZip2Stream.read(uncompressedBytes, 0, BUFFER_SIZE);
bZip2Stream.close();
return uncompressedBytes;
}
在这段代码中,我采用了一个压缩的字节数组,使用 bZip2 压缩,然后尝试解压缩它。
字节数组compressedBytes 中有部分文件。(高达 2 kB 的 BUFFER_SIZE,实际文件为 25 kB)。
我只需要解压缩部分文件,因为文件可能很大。我不明白,为什么我得到Unexpected end of stream
错误。我有类似的 GZip 代码可以正常工作。