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

org.dellroad.lzma.client.LZMAByteArrayCompressor Maven / Gradle / Ivy

Go to download

gwt-lzma is a GWT module that implements the Lempel-Ziv-Markov chain (LZMA) compression algorithm. This is a generic compression library, i.e., compression in Javascript, not just compression of Javascript (i.e., "minification").

There is a newer version: 1.2-8
Show newest version

/*
 * Copyright (C) 2009 Archie L. Cobbs. All rights reserved.
 *
 * $Id$
 */

package org.dellroad.lzma.client;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * LZMA compressor for {@code byte[]} arrays.
 */
public class LZMAByteArrayCompressor extends LZMACompressor {

    private final ByteArrayOutputStream output;

    /**
     * Construct an encoder using the {@link #DEFAULT_COMPRESSION_MODE default compression mode}.
     *
     * 

* This is a convenience constructor, equivalent to: *

* LZMACompressor(data, DEFAULT_COMPRESSION_MODE) *
*/ public LZMAByteArrayCompressor(byte[] data) { this(data, DEFAULT_COMPRESSION_MODE); } /** * Primary constructor. * * @param data uncompressed data * @param mode compression mode * @throws IllegalArgumentException if {@code mode} is null */ public LZMAByteArrayCompressor(byte[] data, CompressionMode mode) { this.output = new ByteArrayOutputStream(); try { init(new ByteArrayInputStream(data), this.output, data.length, mode); } catch (IOException e) { throw new RuntimeException("impossible exception"); } } /** * Get the compressed data. */ public byte[] getCompressedData() { return this.output.toByteArray(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy