gzip对象
/* from 时 代 J a v a 公 众 号 */ //package com.nowjava; import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.zip.GZIPOutputStream; public class Main { public static byte[] gzipObject(Serializable data) throws IOException { ByteArrayOutputStream baOut = null; GZIPOutputStream gzOut = null; ObjectOutputStream objOut = null; try { /** 时代Java公众号 提供 **/ baOut = new ByteArrayOutputStream(); gzOut = new GZIPOutputStream(baOut); objOut = new ObjectOutputStream(gzOut); objOut.writeObject(data); gzOut.finish(); gzOut.flush(); return baOut.toByteArray(); } finally { closeQuietly(objOut); closeQuietly(gzOut); closeQuietly(baOut); } } public static void closeQuietly(