title: How to read a text file using Relative path in scala
body: <p>I have a simple mvn project written in scala. I want to access a text file and read its content. The code is working fine but the only issue is I am giving the absolute path when reading the text file. Following is the directory structure of my project.</p>
  
  <p>How can I use the relative path to read that file? 
  (Do I have to move the movies.txt file in to the resources directory, if so still how would I read that file?)</p>
  
  <p>Any insight will be much appreciated. Thank you </p>
  
  <pre><code>myproject
  |-src
  |  |-resources
  |  |-scala
  |      |-movies.simulator
  |           |-Boot
  |           |-Simulate
  |                |-myobject.scala
  |                      |Simulate
  |
  |-target
  |-pom.xml
  |-README
  |-movies.txt
  </code></pre>
  
  <p>In the myobject.scala where the Simulate is the package object, I access the movies.txt file using the absolute path.</p>
  
  <pre><code>import scala.io.Source
  Source
      .fromFile("/home/eshan/projecs/myproject/movies.txt")
      .getLines
      .foreach { line =&gt;
      count+=1
        // custom code            
  }
  </code></pre>