Example usage for org.apache.commons.compress.compressors CompressorInputStream getClass

List of usage examples for org.apache.commons.compress.compressors CompressorInputStream getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.quanticate.opensource.compressingcontentstore.DecompressingContentReader.java

@Override
protected ReadableByteChannel getDirectReadableChannel() throws ContentIOException {
    // Get a Channel onto the real data
    ReadableByteChannel rawChannel = getRawChannel();

    // Wrap this as an InputStream - Commons Compress is Stream not Channel based
    // Note that Commons Compress needs to mark/reset a bit to identify
    InputStream rawInp = new BufferedInputStream(Channels.newInputStream(rawChannel), 32);

    // Try to process it as a compressed stream
    try {//from   ww  w  .  j  a  va 2  s .  c  om
        CompressorInputStream decompressed = new CompressorStreamFactory().createCompressorInputStream(rawInp);
        logger.debug("Detected compressed data as " + decompressed.getClass().getName());
        return Channels.newChannel(decompressed);
    } catch (CompressorException e) {
        logger.info("Unable to decompress " + realContentReader, e);
    }

    // Tidy up that channel, and re-fetch the real one
    try {
        rawInp.close();
        rawChannel.close();
    } catch (IOException e) {
        logger.warn("Error tidying up", e);
    }

    logger.debug("Using raw form for " + getContentUrl());
    return getRawChannel();
}