Browse topics
Standard Library
File I/O
Read and write files, lines and path operations in Kotlin.
kotlin file ioRead Text File in KotlinreadText reads entire file content as String. A Kotlin example with source code and sample output.kotlin file ioWrite Text File in KotlinwriteText writes string content to a file. A Kotlin example with source code and sample output.kotlin file ioRead Lines from File in KotlinreadLines returns list of lines from a text file. A Kotlin example with source code and sample output.kotlin file ioFile Exists Check in Kotlinexists() checks whether file or directory is present. A Kotlin example with source code and sample output.kotlin file ioFile Path Operations in KotlinFile class provides name, parent and absolutePath properties. A Kotlin example with source code and sample output.kotlin file iouse Function for Resources in KotlinThe use extension closes Closeable resources automatically, even when exceptions occur. A Kotlin example with source code and sample output.