Here you can find the source of uncompress(final byte[] compressedData)
Parameter | Description |
---|---|
compressedData | Entrada a descomprimir. |
static byte[] uncompress(final byte[] compressedData)
//package com.java2s; /* Copyright (C) 2011 [Gobierno de Espana] * This file is part of "Cliente @Firma". * "Cliente @Firma" is free software; you can redistribute it and/or modify it under the terms of: * - the GNU General Public License as published by the Free Software Foundation; * either version 2 of the License, or (at your option) any later version. * - or The European Software License; either version 1.1 or (at your option) any later version. * Date: 11/01/11//from w ww .j a v a2s . c o m * You may contact the copyright holder at: soporte.afirma5@mpt.es */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.logging.Logger; import java.util.zip.Inflater; public class Main { private static final int COMPRESS_BUFFER_SIZE = 1024; /** Método que descomprime una entrada. * @param compressedData Entrada a descomprimir. * @return Entrada descomprimida. */ static byte[] uncompress(final byte[] compressedData) { // Creamos el descompresor y le pasamos los datos final Inflater decompressor = new Inflater(); decompressor.setInput(compressedData); final ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length); // Descomprimimos final byte[] buf = new byte[COMPRESS_BUFFER_SIZE]; while (!decompressor.finished()) { try { final int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (final Exception e) { Logger.getLogger("es.gob.afirma").severe("Error descomprimiendo los datos: " + e); //$NON-NLS-1$ //$NON-NLS-2$ break; } } try { bos.close(); } catch (final IOException e) { // Ignoramos los errores en el cierre } return bos.toByteArray(); } }