Example usage for org.apache.commons.compress.bzip2 CBZip2OutputStream write

List of usage examples for org.apache.commons.compress.bzip2 CBZip2OutputStream write

Introduction

In this page you can find the example usage for org.apache.commons.compress.bzip2 CBZip2OutputStream write.

Prototype

public void write(byte b[], int off, int len) throws IOException 

Source Link

Document

Writes len bytes from the specified byte array starting at offset off to this output stream.

Usage

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;
}