Java Unzip InputStream decompress(ByteArrayInputStream xzStream)

Here you can find the source of decompress(ByteArrayInputStream xzStream)

Description

Compression temporarily disabled due to problems on full hd devices. Decompress a previously compressed Xz stream

License

Open Source License

Parameter

Parameter Description
xzStream the compressed file

Exception

Parameter Description
IOException if any error occurs during decompression

Return

the original file (notice that if file was compressed using JPEG, you will not be able to retrieve the original file)

Declaration


public static ByteArrayInputStream decompress(ByteArrayInputStream xzStream) throws IOException 

Method Source Code

//package com.java2s;
/*//from  w w w .j  av a2  s .  c om
 * (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
 *
 * This file is part of the software Remote Resources
 *
 * All rights reserved. This file and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 3.0 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This file is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */

import java.io.ByteArrayInputStream;

import java.io.IOException;

public class Main {
    /**
     * <b>Compression temporarily disabled due to problems on full hd
     * devices.</b> Decompress a previously compressed Xz stream
     * 
     * @param xzStream
     *            the compressed file
     * @return the original file (notice that if file was compressed using JPEG,
     *         you will not be able to retrieve the original file)
     * @throws IOException
     *             if any error occurs during decompression
     */

    public static ByteArrayInputStream decompress(ByteArrayInputStream xzStream) throws IOException {
        ByteArrayInputStream xzInputStream = xzStream;
        byte firstByte = (byte) xzInputStream.read();
        byte[] buffer = new byte[xzInputStream.available()];
        buffer[0] = firstByte;
        xzInputStream.read(buffer, 1, buffer.length - 2);
        xzInputStream.close();
        return new ByteArrayInputStream(buffer);
    }
}

Related

  1. decompress(final int type, final InputStream is, final OutputStream os)
  2. decompress(InputStream input, File destDir)
  3. decompress(InputStream inputStream)
  4. decompress(InputStream is, OutputStream os)