# How to read a file ?

Module:
Tags: basic scala
scala.io.Source.fromFile("fileName").getLines().next()

Note

.fromFile takes the fullName with the path. If the file is kept directly under the project, then just giving the filename workd. But if the file is kept inside a folder then while reading we need to provide the <folder_name>/<file_name> scala.io.Source.fromFile("<folder_name>/<file_name>").getLines().next()

As a practice is better to put the filename with the path in a conf file and read from that. read property from conf