@Throws(IOException::class) fun <K, V> writeMap(map: Map<K, V>, stream: ObjectOutputStream) { stream.writeInt(map.size) for ((key, value): Map.Entry<K, V> in map) { stream.writeObject(key) stream.writeObject(value) } }
Stores the contents of a map in an output stream , as part of serialization . It does not support concurrent maps whose content may change while the method is running . < p > The serialized output consists of the number of entries , first key , first value , second key , second value , and so on .