Code example for ObjectInputStream

Methods: close, readObject

0
public final class Utilities 
{ 
	public static HashMap<Integer, MetaData> LoadLocalMetadata(String filename) throws ClassNotFoundException, IOException 
	{ 
		FileInputStream fin = new FileInputStream(filename);
		ObjectInputStream oin = new ObjectInputStream(fin);
		@SuppressWarnings("unchecked") 
		HashMap<Integer, MetaData> ret = (HashMap<Integer, MetaData>) oin.readObject();
		oin.close();
		return ret;
	} 
	 
	public static void SaveLocalMetadata(String filename, HashMap<Integer, MetaData> metadata) throws IOException
	{ 
		 
		FileOutputStream fout = new FileOutputStream(filename);
		ObjectOutputStream oout = new ObjectOutputStream(fout);
		oout.writeObject(metadata);
	} 
	 
	// Suppress default constructor for noninstantiability