Here you can find the source of saveObject(Serializable obj, String url)
Parameter | Description |
---|---|
obj | the serializable object to be stored |
url | the path to be stored |
public static void saveObject(Serializable obj, String url)
//package com.java2s; //License from project: LGPL import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class Main { /**/* w ww .j ava 2s. com*/ * Saves an Serializable Object to the hard disk. * * @param obj * the serializable object to be stored * @param url * the path to be stored */ public static void saveObject(Serializable obj, String url) { try { FileOutputStream fOut = new FileOutputStream(url); ObjectOutputStream objOut = new ObjectOutputStream(fOut); objOut.writeObject(obj); } catch (Exception e) { System.err.println(e.getMessage()); } } }