Here you can find the source of decompressByZLIB(byte[] compressedBytes)
Parameter | Description |
---|---|
compressedBytes | Compressed bytes |
public static byte[] decompressByZLIB(byte[] compressedBytes)
//package com.java2s; // The MIT License import java.io.ByteArrayOutputStream; import java.util.zip.Inflater; public class Main { /**/*from www . ja v a 2s.com*/ * Uncompresses the given byte array by the ZLIB algorithm. * @param compressedBytes Compressed bytes * @return Uncompressed bytes */ public static byte[] decompressByZLIB(byte[] compressedBytes) { try { Inflater inflater = new Inflater(); inflater.setInput(compressedBytes); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream( compressedBytes.length); byte[] buffer = new byte[1024]; while (!inflater.finished()) { int count = inflater.inflate(buffer); byteArrayOutputStream.write(buffer, 0, count); } byteArrayOutputStream.close(); return byteArrayOutputStream.toByteArray(); } catch (Exception exception) { throw new IllegalStateException(exception.getMessage()); } } }