}
@Override
ByteBuffer decompress(ByteBuffer compressedData) throws IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(compressedData.array());
BZip2CompressorInputStream inputStream = new BZip2CompressorInputStream(bais);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int readCount = -1;
while ( (readCount = inputStream.read(buffer, compressedData.position(), buffer.length))> 0) {
baos.write(buffer, 0, readCount);
}
ByteBuffer result = ByteBuffer.wrap(baos.toByteArray());
return result;
} finally {
inputStream.close();
}
}