readText

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

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

This method is not recommended on huge files. It has an internal limitation of 2 GB file size.

Since Kotlin

1.0

Return

the entire content of this file as a String.

Parameters

charset

character set to use.


Reads this reader completely as a String.

Note: It is the caller's responsibility to close this reader.

Since Kotlin

1.0

Return

the string with corresponding file content.


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

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

This method is not recommended on huge files.

Since Kotlin

1.0

Return

a string with this URL entire content.

Parameters

charset

a character set to use.