Zum Inhalt springen

Read Whole File (ARCH8086)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key kotlin.performance.read-whole-file · Severity info · Category performance

Flags readLines() / readText() / readBytes() on a File followed by iteration - the whole file sits in memory when useLines / buffered streaming would not.

file.readLines().forEach { parse(it) }
file.useLines { lines -> lines.forEach { parse(it) } }

Stream with useLines / bufferedReader().use for files that can be large.