Example usage for org.apache.commons.compress.compressors CompressorStreamFactory BZIP2

List of usage examples for org.apache.commons.compress.compressors CompressorStreamFactory BZIP2

Introduction

In this page you can find the example usage for org.apache.commons.compress.compressors CompressorStreamFactory BZIP2.

Prototype

String BZIP2

To view the source code for org.apache.commons.compress.compressors CompressorStreamFactory BZIP2.

Click Source Link

Document

Constant used to identify the BZIP2 compression algorithm.

Usage

From source file:rv.comm.rcssserver.TarBz2ZipUtil.java

/**
 * Creates the writer as zip, bz2 or unpacked stream
 * /*  www . j a v  a2 s .  co m*/
 * @return the writer used for sequential reading
 * @throws IOException
 */
public static PrintWriter createPrintWriter(File file) throws IOException {
    Writer writer = null;
    if (isTarBZ2Ending(file)) {
        // TODO: add support for tar writing
        writer = getCompressingWriter(file, CompressorStreamFactory.BZIP2);

    } else if (isBZ2Ending(file)) {
        writer = getCompressingWriter(file, CompressorStreamFactory.BZIP2);

    } else if (isGZipEnding(file)) {
        writer = getCompressingWriter(file, CompressorStreamFactory.GZIP);

    } else {
        writer = new FileWriter(file);
    }

    return new PrintWriter(new BufferedWriter(writer));
}