izac89
izac89

Reputation: 3940

Cannot run a simple application in Scala

Given the following code:

import scala.io.Source

object Demo {

    def func():Unit = {
        for ( line <- Source.fromFile("C:\Users\Hen\Scala_workspace\Itay\src\Demo.scala").getLines() ) {
            println(line)
        }
    }

    def main(args: Array[String]): Unit = {
        //var x=args(0).toInt;
        func();
    }
}

Why is the pathname marked as a compilation error?
Eclispe won't let me run it

Upvotes: 1

Views: 88

Answers (1)

Paolo Falabella
Paolo Falabella

Reputation: 25874

Try triple quotes around your path, so that scala will not interpret \ + char as special characters:

"""C:\Users\Hen\Scala_workspace\Itay\src\Demo.scala"""

Upvotes: 7

Related Questions