Here you can find the source of saveObjectToFile(Object obj, String fileName)
public static void saveObjectToFile(Object obj, String fileName)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void saveObjectToFile(Object obj, String fileName) { try (ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(fileName))) { stream.writeObject(obj);// www . ja v a 2 s . c o m } catch (IOException e) { throw new RuntimeException(e); } } }