Here you can find the source of readFile(String filePathName)
public static Object readFile(String filePathName)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static Object readFile(String filePathName) { ObjectInputStream oin = null; try {//www . ja v a2 s. co m File file = new File(filePathName); if (!file.exists()) { file.createNewFile(); } oin = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file))); Object obj = oin.readObject(); return obj; } catch (Exception err) { err.printStackTrace(); } finally { try { oin.close(); } catch (Exception e) { e.printStackTrace(); } } return null; } }