Here you can find the source of serializeGZip(T obj)
public static <T extends Externalizable> byte[] serializeGZip(T obj)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.zip.GZIPOutputStream; public class Main { public static <T extends Externalizable> byte[] serializeGZip(T obj) { try {/*from w ww . j a va2 s .c om*/ return serializeGZipSafe(obj); } catch (Exception e) { throw new RuntimeException(e); } } public static <T extends Externalizable> byte[] serializeGZipSafe(T obj) throws IOException, ClassNotFoundException { ByteArrayOutputStream baos = null; try { baos = new ByteArrayOutputStream(); GZIPOutputStream gzip = null; try { gzip = new GZIPOutputStream(baos); ObjectOutput out = null; try { out = new ObjectOutputStream(gzip); obj.writeExternal(out); out.flush(); } finally { if (out != null) { try { out.close(); } catch (Exception e) { /* NOP */ } } } gzip.finish(); gzip.flush(); } finally { if (gzip != null) { try { gzip.close(); } catch (Exception e) { /* NOP */ } } } baos.flush(); return baos.toByteArray(); } finally { if (baos != null) { try { baos.close(); } catch (Exception e) { /* NOP */ } } } } }