Example usage for org.apache.commons.compress.compressors.xz XZCompressorOutputStream write

List of usage examples for org.apache.commons.compress.compressors.xz XZCompressorOutputStream write

Introduction

In this page you can find the example usage for org.apache.commons.compress.compressors.xz XZCompressorOutputStream write.

Prototype

@Override
    public void write(final int b) throws IOException 

Source Link

Usage

From source file:kr.debop4j.core.compress.XZCompressor.java

@Override
protected byte[] doCompress(byte[] plain) throws IOException {

    @Cleanup/*from w  w  w . ja  va  2s.co  m*/
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    @Cleanup
    XZCompressorOutputStream xz = new XZCompressorOutputStream(bos);

    xz.write(plain);
    xz.close();

    return bos.toByteArray();
}

From source file:org.apache.camel.processor.aggregate.XZDataFormatTest.java

protected byte[] getCompressedBody() throws IOException {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    XZCompressorOutputStream zout = new XZCompressorOutputStream(bout);
    try {/*  w w w  . ja v  a  2  s.c  om*/
        zout.write(getPlainTextBody().getBytes("UTF-8"));
    } finally {
        IOHelper.close(zout);
    }
    return bout.toByteArray();
}