Here you can find the source of decompress(byte[] bytes)
byte
array
Parameter | Description |
---|---|
bytes | <code>byte</code> array to decompress |
Parameter | Description |
---|---|
DataFormatException | if anything happens |
IOException | if anything happens |
byte
array
public static byte[] decompress(byte[] bytes) throws DataFormatException, IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.DataFormatException; import java.util.zip.Inflater; public class Main { private static final Inflater inflater = new Inflater(); /**/*from www.j ava 2 s . c o m*/ * Decompress <code>byte</code> array * @param bytes <code>byte</code> array to decompress * @return decompressed <code>byte</code> array * @throws DataFormatException if anything happens * @throws IOException if anything happens */ public static byte[] decompress(byte[] bytes) throws DataFormatException, IOException { inflater.setInput(bytes); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(bytes.length); byte[] buffer = new byte[1024]; while (!inflater.finished()) { int count = inflater.inflate(buffer); outputStream.write(buffer, 0, count); } outputStream.close(); byte[] output = outputStream.toByteArray(); inflater.reset(); return output; } }