@SuppressWarnings("unchecked") public static <T extends Serializable>T read(File file) throws ClassNotFoundException, IOException {
  try (ObjectInputStream input=new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)))){
    return (T)input.readObject();
  }
 }

@ SuppressWarnings ( "unchecked" ) public static < T extends Serializable > T read ( File file ) throws ClassNotFoundException , IOException { try ( ObjectInputStream input = new ObjectInputStream ( new BufferedInputStream ( new FileInputStream ( file ) ) ) ) { return ( T ) input . readObject ( ) ; } }
reads an object from the given file .
