code: static <K, V> void populateMap(Map<K, V> map, ObjectInputStream stream, int size)
        throws IOException, ClassNotFoundException {
      for (int i = 0; i < size; i++) {
        @SuppressWarnings("unchecked") // reading data stored by writeMap
        K key = (K) stream.readObject();
        @SuppressWarnings("unchecked") // reading data stored by writeMap
        V value = (V) stream.readObject();
        map.put(key, value);
      }
    }
docs: Populates a map by reading an input stream, as part of deserialization. See {@link #writeMap}
  for the data format. The size is determined by a prior call to {@link #readCount}.