Example usage for java.util.zip ZipException printStackTrace

List of usage examples for java.util.zip ZipException printStackTrace

Introduction

In this page you can find the example usage for java.util.zip ZipException printStackTrace.

Prototype

public void printStackTrace(PrintStream s) 

Source Link

Document

Prints this throwable and its backtrace to the specified print stream.

Usage

From source file:ZipDemo.java

public static final String uncompress(final byte[] compressed) throws IOException {
    String uncompressed = "";

    try {//from  w w w.ja va 2s .  c o  m
        ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
        GZIPInputStream zis = new GZIPInputStream(bais);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int numBytesRead = 0;
        byte[] tempBytes = new byte[DEFAULT_BUFFER_SIZE];
        while ((numBytesRead = zis.read(tempBytes, 0, tempBytes.length)) != -1) {
            baos.write(tempBytes, 0, numBytesRead);
        }

        uncompressed = new String(baos.toByteArray());
    } catch (ZipException e) {
        e.printStackTrace(System.err);
    }

    return uncompressed;
}