Java tutorial
//package com.java2s; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; public class Main { public static boolean writeSerialize(FileOutputStream outputStream, Serializable obj) { try (ObjectOutputStream out = new ObjectOutputStream(outputStream)) { out.writeObject(obj); out.flush(); return true; } catch (IOException e) { return false; } } }