Kotlin – Check if File exists

Kotlin – Check if File exists : In Kotlin, to check if the file already exists, use File.exists(). File.exists() returns a Boolean value. It returns true if the file exists and false if the file does not exist.

Example – Check if File exists

In the following example we shall check if the a file “data.txt” exists.