List of usage examples for org.apache.commons.compress.bzip2 CBZip2OutputStream close
public void close() throws IOException
From source file:ch.rgw.compress.CompEx.java
public static byte[] CompressBZ2(InputStream in) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[8192]; baos.write(buf, 0, 4); // Lnge des Originalstroms CBZip2OutputStream bzo = new CBZip2OutputStream(baos); int l;//from w ww . java2 s. c om int total = 0; ; while ((l = in.read(buf, 0, buf.length)) != -1) { bzo.write(buf, 0, l); total += l; } bzo.close(); byte[] ret = baos.toByteArray(); // Die hchstwertigen 3 Bit als Typmarker setzen total &= 0x1fffffff; total |= BZIP2; BinConverter.intToByteArray(total, ret, 0); return ret; }