title: How can I get the project path in Scala?
body: <p>I'm trying to read some files from my Scala project, and if I use: <code>java.io.File(".").getCanonicalPath()</code> I find that my current directory is far away from them (exactly where I have installed Scala Eclipse). So how can I change the current directory to the root of my project, or get the path to my project? I really don't want to have an absolute path to my input files.</p>
  
  <pre><code>  val PATH = raw"E:\lang\scala\progfun\src\examples\"
    def printFileContents(filename: String) {
      try {
        println("\n" + PATH + filename)
        io.Source.fromFile(PATH + filename).getLines.foreach(println)
      } catch {
        case _:Throwable =&gt; println("filename " + filename + " not found")
      }
    }
  
    val filenames = List("random.txt", "a.txt", "b.txt", "c.txt")
    filenames foreach printFileContents
  </code></pre>