Code example for ObjectOutputStream

Methods: closeflushwriteObject

0
     * @param path Patha to save to 
     * @throws Exception  
     */ 
    public static void save(Object obj,String path) throws Exception
	{ 
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(path));
		oos.writeObject(obj);
		oos.flush();
		oos.close();
	} 
    /** 
     * Loads a specified object from a location 
     * @param Path to load from 
     * @return Loaded object 
     * @throws Exception  
     */ 
	public static Object load(String path) throws Exception
	{ 
		ObjectInputStream ois = new ObjectInputStream(new FileInputStream(path));
		Object result = ois.readObject();