Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; public class Main { public static Object readAsObject(File source) throws IOException, ClassNotFoundException { FileInputStream in = new FileInputStream(source); try { ObjectInputStream oi = new ObjectInputStream(in); return oi.readObject(); } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } }