Here you can find the source of deserializeFromFile(String path)
public static <T extends Serializable> T deserializeFromFile(String path) throws IOException, ClassNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.Serializable; public class Main { public static <T extends Serializable> T deserializeFromFile(String path) throws IOException, ClassNotFoundException { FileInputStream fileIn = new FileInputStream(path); T e = deserialize(fileIn);//w ww.j a v a 2s.co m fileIn.close(); return e; } public static <T extends Serializable> T deserialize(InputStream is) throws IOException, ClassNotFoundException { ObjectInputStream in = new ObjectInputStream(is); @SuppressWarnings("unchecked") T e = (T) in.readObject(); in.close(); return e; } }