How to make my save/load to/from file function more canonical?
Converting a list of Ints to a comma separated string

map.forEach {
    out.println("${it.key}:${it.value.toString().replace("[", "").replace("]", "").replace(" ", "")}")
}


This could be refactored as:

map.map { (key, value) -&gt;
    key + ":" + value.joinToString(",") { it.toString() }
}.forEach(out::println)


Loading data into the map

val map = mutableMapOf&lt;String, List&lt;Int&gt;&gt;()
map.put("first", listOf(1, 2, 3))
map.put("second", listOf(4, 5, 6))


This can be rewitten to use mapOf, which increases readability

val map = mutableMapOf(
        "first" to listOf(1, 2, 3),
        "second" to listOf(4, 5, 6)
)


Destructuring declaration for splitting string

val parts = it.split(":")
map.put(parts[0], parts[1].split(",").map { it.toInt() })


Using a destructuring declaration may make the purpose of this code clearer.

val (key, values) = "a".split(":")
map.put(key, values.split(",").map { it.toInt() })