Here you can find the source of readObjectFromFile(File fileLocation)
@SuppressWarnings("unchecked") public static <T> T readObjectFromFile(File fileLocation) throws IOException
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.util.zip.GZIPInputStream; public class Main { @SuppressWarnings("unchecked") public static <T> T readObjectFromFile(File fileLocation) throws IOException { InputStream file = new FileInputStream(fileLocation); InputStream buffer = new GZIPInputStream(file); try (ObjectInput input = new ObjectInputStream(buffer)) { return (T) input.readObject(); } catch (ClassNotFoundException e) { // Need to handle only one exception throw new IOException(e); }//from w ww. ja v a2s . c o m } }