Here you can find the source of loadData(Class
public static <T> T loadData(Class<T> expectedClass, String filename)
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.ObjectInputStream; public class Main { public static <T> T loadData(Class<T> expectedClass, String filename) { T o = null;/*from w w w .j av a 2 s. co m*/ try { FileInputStream fi = new FileInputStream(filename); ObjectInputStream oi = new ObjectInputStream(fi); o = expectedClass.cast(oi.readObject()); oi.close(); fi.close(); } catch (Exception e) { } return o; } }