Example usage for org.apache.commons.compress.compressors.bzip2 BZip2CompressorInputStream getBytesRead

List of usage examples for org.apache.commons.compress.compressors.bzip2 BZip2CompressorInputStream getBytesRead

Introduction

In this page you can find the example usage for org.apache.commons.compress.compressors.bzip2 BZip2CompressorInputStream getBytesRead.

Prototype

public long getBytesRead() 

Source Link

Document

Returns the current number of bytes read from this stream.

Usage

From source file:net.orpiske.ssps.common.archive.CompressedArchiveUtils.java

/**
 * Decompress a file//from  w ww  .  j av  a 2  s.c  om
 * @param source the source file to be uncompressed
 * @param destination the destination directory
 * @return the number of bytes read
 * @throws IOException for lower level I/O errors
 */
public static long bzipDecompress(File source, File destination) throws IOException {
    FileOutputStream out;

    prepareDestination(destination);

    out = new FileOutputStream(destination);

    FileInputStream fin = null;
    BufferedInputStream bin = null;
    BZip2CompressorInputStream bzIn = null;

    try {
        fin = new FileInputStream(source);
        bin = new BufferedInputStream(fin);
        bzIn = new BZip2CompressorInputStream(bin);

        IOUtils.copy(bzIn, out);

        bzIn.close();

        fin.close();
        bin.close();
        out.close();
    } catch (IOException e) {
        IOUtils.closeQuietly(out);

        IOUtils.closeQuietly(fin);
        IOUtils.closeQuietly(bin);
        IOUtils.closeQuietly(bzIn);

        throw e;
    }

    return bzIn.getBytesRead();
}