}
public static void compress(InputStream in, OutputStream out)
throws IOException
{
LZFOutputStream compressor = null;
boolean success = true;
try {
compressor = new LZFOutputStream(out);
byte[] buf = ThreadLocalByteBuffer.getBuffer();
int len;
while ((len = in.read(buf)) != -1) {
compressor.write(buf, 0, len);
}
compressor.close();
} catch (IOException e) {
success = false;
throw new IllegalStateException(e.getMessage(), e);
} finally {
if (!success && (compressor != null)) {
compressor.close();
}
}
}