Do not use file length estimate in File.readText

This handles the situation when reported file length is less than actual.

#KT-33864
This commit is contained in:
Ilya Gorbunov
2019-09-25 18:22:15 +03:00
parent fe31509044
commit c9dd8344d1
@@ -122,7 +122,7 @@ public fun File.appendBytes(array: ByteArray): Unit = FileOutputStream(this, tru
* @param charset character set to use.
* @return the entire content of this file as a String.
*/
public fun File.readText(charset: Charset = Charsets.UTF_8): String = readBytes().toString(charset)
public fun File.readText(charset: Charset = Charsets.UTF_8): String = reader(charset).use { it.readText() }
/**
* Sets the content of this file as [text] encoded using UTF-8 or specified [charset].