Example usage for java.util.zip DataFormatException toString

List of usage examples for java.util.zip DataFormatException toString

Introduction

In this page you can find the example usage for java.util.zip DataFormatException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:Main.java

public static byte[] decompressZLIB(byte[] input) throws IOException {
    Inflater decompressor = new Inflater();
    decompressor.setInput(input);//w  ww  .  j a  v a  2 s.co  m
    // Create an expandable byte array to hold the decompressed data
    ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length);

    // Decompress the data
    byte[] buf = new byte[1024];
    while (!decompressor.finished()) {
        try {
            int count = decompressor.inflate(buf);
            bos.write(buf, 0, count);
        } catch (DataFormatException e) {
            throw new IOException(e.toString());
        }
    }
    bos.close();

    // Get the decompressed data
    byte[] decompressedData = bos.toByteArray();
    return decompressedData;
}

From source file:org.apache.lucene.index.FieldsReader.java

private byte[] uncompress(byte[] b) throws CorruptIndexException {
    try {/*  w w  w. j  a va2 s.c om*/
        return CompressionTools.decompress(b);
    } catch (DataFormatException e) {
        // this will happen if the field is not compressed
        CorruptIndexException newException = new CorruptIndexException(
                "field data are in wrong format: " + e.toString());
        newException.initCause(e);
        throw newException;
    }
}