writeText

fun Path.writeText(text: CharSequence, charset: Charset = Charsets.UTF_8, vararg options: OpenOption)(source)

Sets the content of this file as text encoded using UTF-8 or the specified charset.

By default, the file will be overwritten if it already exists, but you can control this behavior with options.

Since Kotlin

1.5

Parameters

text

text to write into file.

charset

character set to use for writing text, UTF-8 by default.

options

options to determine how the file is opened.