public static Object read(InputStream stream) throws Exception {
  ObjectInputStream ois;
  Object result;
  if (!(stream instanceof BufferedInputStream)) {
    stream=new BufferedInputStream(stream);
  }
  ois=new ObjectInputStream(stream);
  result=ois.readObject();
  ois.close();
  return result;
}

public static Object read ( InputStream stream ) throws Exception { ObjectInputStream ois ; Object result ; if ( ! ( stream instanceof BufferedInputStream ) ) { stream = new BufferedInputStream ( stream ) ; } ois = new ObjectInputStream ( stream ) ; result = ois . readObject ( ) ; ois . close ( ) ; return result ; }
deserializes from the given stream and returns the object from it .
