Here you can find the source of gunzip(final byte[] b, final Class
Parameter | Description |
---|---|
b | gziped byte array. |
Parameter | Description |
---|---|
JSONException | an exception |
IOException | an exception |
public static final <T> T gunzip(final byte[] b, final Class<T> c) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; import com.fasterxml.jackson.databind.ObjectMapper; public class Main { private static final ObjectMapper MAPPER = new ObjectMapper(); /**/* w w w . j av a 2 s . c om*/ * return JSON form. * @param b gziped byte array. * @return JSON string. * @throws JSONException * @throws IOException */ public static final <T> T gunzip(final byte[] b, final Class<T> c) throws IOException { if (b == null) { return null; } try (final GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(b))) { return MAPPER.readValue(in, c); } } }