Here you can find the source of save(Serializable serialized, String filepath)
public static void save(Serializable serialized, String filepath)
//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.io.OutputStream; import java.io.Serializable; import java.util.zip.GZIPOutputStream; public class Main { public static void save(Serializable serialized, String filepath) { save(serialized, new File(filepath)); }//from w ww . jav a 2 s .c o m public static void save(Serializable serialized, File file) { try { OutputStream fout = new FileOutputStream(file); if (file.getName().endsWith(".gz")) fout = new GZIPOutputStream(fout); ObjectOutputStream out = new ObjectOutputStream(fout); out.writeObject(serialized); out.close(); } catch (IOException e) { throw new RuntimeException(e); } } }