Here you can find the source of serialize(Object obj, String fname, boolean gzipped)
public static void serialize(Object obj, String fname, boolean gzipped)
//package com.java2s; // This software is released under the 2-clause BSD license. import java.io.*; import java.util.zip.*; public class Main { public static void serialize(Object obj, String fname, boolean gzipped) { serialize(obj, new File(fname), gzipped); }/*from ww w . ja va 2s . com*/ public static void serialize(Object obj, String fname) { serialize(obj, new File(fname), false); } public static void serialize(Object obj, File f) { serialize(obj, f, false); } public static void serialize(Object obj, File f, boolean gzipped) { try { OutputStream os = new FileOutputStream(f); if (gzipped) os = new GZIPOutputStream(os); ObjectOutputStream oos = new ObjectOutputStream(os); oos.writeObject(obj); oos.close(); } catch (Exception e) { throw new RuntimeException(e); } } }