I have a Kotlin class with a method, which creates some text and then I want to write it to a file:
import java.io.File
import java.util.*
import kotlin.io.*
class MyClass {
fun run() {
val result = html {
head {
title { +"Entry page" }
}
body {
h1 {
+"Map"
}
+"Some HTML code"
}
}
File("target/wdef/index.html").writeText(result)
}
}
I get an error - the writeText(result)
is highlighted red and I get the error message Error:(26, 40) Kotlin: Unresolved reference: writeText
.
How can I fix it?