Import the File.separator constant and assign an alias to it:
import java.io.File.separator as SEPARATOR
Declare a String storing a path to the file we are going to read:
val filePahtName = "src${SEPARATOR}main${SEPARATOR}resources${SEPARATOR}file1.txt"
Instantiate a File using the specified path:
val filePahtName = "src${SEPARATOR}main${SEPARATOR}resources${SEPARATOR}file1.txt" val file = File(filePahtName)
Read the text from the file and print it to the console:
val filePahtName = "src${SEPARATOR}main${SEPARATOR}resources${SEPARATOR}file1.txt" val file = File(filePahtName) val fileText: String = file.readText() println(fileText)