Search code examples
filescalaplayframework-2.2filenotfoundexception

Getting cannot find file exception in Play Framework


I have a file called product.csv in my application root. I want to read from the file. But I am getting file not found exception. Here is the code I have written.

val lines = scala.io.Source.fromFile("/product.csv").mkString
println(lines)

What am I doing wrong?

I am using Windows OS.


Solution

  • You need to use a relative filepath "product.csv" rather than "/product.csv" which will look at the root of your drive.