List of usage examples for org.apache.commons.compress.bzip2 CBZip2OutputStream write
public void write(byte b[], int off, int len) throws IOException
len
bytes from the specified byte array starting at offset off
to this output stream. 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 www .j av a 2 s. com 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; }