All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ning.compress.UncompressorOutputStream Maven / Gradle / Ivy

Go to download

Compression codec for LZF encoding for particularly encoding/decoding, with reasonable compression. Compressor is basic Lempel-Ziv codec, without Huffman (deflate/gzip) or statistical post-encoding. See "http://oldhome.schmorp.de/marc/liblzf.html" for more on original LZF package.

There is a newer version: 1.1.2
Show newest version
package com.ning.compress;

import java.io.*;

/**
 * Simple wrapper or wrapper around {@link Uncompressor}, to help
 * with inter-operability.
 */
public class UncompressorOutputStream extends OutputStream
{
    protected final Uncompressor _uncompressor;

    private byte[] _singleByte = null;
    
    public UncompressorOutputStream(Uncompressor uncomp)
    {
        _uncompressor = uncomp;
    }

    /**
     * Call to this method will result in call to
     * {@link Uncompressor#complete()}, which is idempotent
     * (i.e. can be called multiple times without ill effects).
     */
    @Override
    public void close() throws IOException {
        _uncompressor.complete();
    }

    @Override
    public void flush() { }

    @Override
    public void write(byte[] b) throws IOException {
        _uncompressor.feedCompressedData(b, 0, b.length);
    }

    @Override
    public void write(byte[] b, int off, int len) throws IOException {
        _uncompressor.feedCompressedData(b, off, len);
    }

    @Override
    public void write(int b)  throws IOException
    {
        if (_singleByte == null) {
            _singleByte = new byte[1];
        }
        _singleByte[0] = (byte) b;
        _uncompressor.feedCompressedData(_singleByte, 0, 1);
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy