Here is a string template read from file.
Dialogue: {0}
Dialogue: {1}
After I read it from file, I want to format this string using given array.
var sentences = arrayOf("hello", "world")
var template = File("file_path").readText()
template = MessageFormat.format(template, sentences)
print(template)
But I get output.
Dialogue: [Ljava.lang.String;@27c170f0
Dialogue: {1}
EDIT
If I put array elements one by one, I will get right output.
MessageFormat.formatacceptObject...and seesentencesas oneObjectnot an array ofObject. In Kotlin not sure what to do... In Java it would be as simple as declaringsentencesas an array.