readText

fun Path.readText(charset: Charset = Charsets.UTF_8): String(source)

Gets the entire content of this file as a String using UTF-8 or the specified charset.

It's not recommended to use this function on huge files. For reading large files or files of unknown size, open a Reader and read blocks of text sequentially.

Since Kotlin

1.5

Return

the entire content of this file as a String.

Parameters

charset

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