Here you can find the source of getObjectFormFile(String filePath)
public static Object getObjectFormFile(String filePath)
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.ObjectInputStream; import java.io.StreamCorruptedException; public class Main { public static Object getObjectFormFile(String filePath) { if (filePath == null || filePath.length() == 0) return null; try {/* ww w . j ava 2 s.c om*/ File file = new File(filePath); if (file.exists()) { ObjectInputStream ois = new ObjectInputStream( new FileInputStream(file)); Object object = ois.readObject(); return object; } } catch (StreamCorruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }