All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.csb.sdk.GZipUtils Maven / Gradle / Ivy

There is a newer version: 1.1.5.11
Show newest version
package com.alibaba.csb.sdk;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;

/**
 * Created by tingbin.ctb
 * 2019/6/20-12:10.
 */
public class GZipUtils {

    static public byte[] gzipBytes(byte[] bytes) throws IOException {
        GZIPOutputStream gzip = null;
        ByteArrayOutputStream out = null;
        try {
            out = new ByteArrayOutputStream();
            gzip = new GZIPOutputStream(out);
            gzip.write(bytes);
            gzip.close();
            return out.toByteArray();
        } finally {
            if (gzip != null) {
                gzip.close();
            }
            if (out != null) {
                out.close();
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy