Here you can find the source of saveGZipObject(Object toSave, File file)
public static boolean saveGZipObject(Object toSave, File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.zip.GZIPOutputStream; public class Main { public static boolean saveGZipObject(Object toSave, File file) { FileOutputStream fos = null; GZIPOutputStream gos = null; ObjectOutputStream oos = null; try {//from ww w . ja v a 2 s . com fos = new FileOutputStream(file); gos = new GZIPOutputStream(fos); oos = new ObjectOutputStream(gos); oos.writeObject(toSave); oos.flush(); oos.close(); gos.close(); fos.close(); } catch (IOException ioe) { ioe.printStackTrace(); return false; } return true; } }