Java tutorial
//package com.java2s; //License from project: Apache License import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { public static void saveSerializableObjectToFile(Object object, FileOutputStream fileOut) { ObjectOutputStream out = null; try { out = new ObjectOutputStream(fileOut); out.writeObject(object); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (out != null) { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } } }