Example usage for org.apache.commons.compress.compressors.xz XZCompressorInputStream read

List of usage examples for org.apache.commons.compress.compressors.xz XZCompressorInputStream read

Introduction

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

Prototype

@Override
    public int read(final byte[] buf, final int off, final int len) throws IOException 

Source Link

Usage

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

@Override
protected byte[] doDecompress(byte[] compressed) throws IOException {

    @Cleanup/*  w ww.  j  av a2s. c  o  m*/
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    @Cleanup
    ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
    @Cleanup
    XZCompressorInputStream xz = new XZCompressorInputStream(bis);

    byte[] buff = new byte[BUFFER_SIZE];
    int n;
    while ((n = xz.read(buff, 0, BUFFER_SIZE)) > 0) {
        bos.write(buff, 0, n);
    }
    return bos.toByteArray();
}