public static void eachObject(ObjectInputStream ois,Closure closure) throws IOException, ClassNotFoundException {
  try {
    while (true) {
      try {
        Object obj=ois.readObject();
        closure.call(obj);
      }
 catch (      EOFException e) {
        break;
      }
    }
    InputStream temp=ois;
    ois=null;
    temp.close();
  }
  finally {
    closeWithWarning(ois);
  }
}

public static void eachObject ( ObjectInputStream ois , Closure closure ) throws IOException , ClassNotFoundException { try { while ( true ) { try { Object obj = ois . readObject ( ) ; closure . call ( obj ) ; } catch ( EOFException e ) { break ; } } InputStream temp = ois ; ois = null ; temp . close ( ) ; } finally { closeWithWarning ( ois ) ; } }
iterates through the given object stream object by object . the objectinputstream is closed afterwards .
