Reputation: 105258
This piece of scala code:
val file = new File(".")
assert(file.exists == true)
assert(file.getAbsolutePath.length > 0)
println(scala.io.Source.fromFile(file).getLines)
Throws:
FileNotFoundException: . (No such file or directory) (FileInputStream.java:120)
While making the scala.io.Source.fromFile
call. How is this possible and how can I fix it?
PS: This is in the context of a playframework app test.
Upvotes: 2
Views: 3410
Reputation: 340953
Maybe because:
assert(file.isDirectory)
passes as well? You cannot really open a directory and read it, you can only open files. BTW on my machine the error is more descriptive:
java.io.FileNotFoundException: . (Is a directory)
Tested on:
$ java -version
java version "1.6.0_26"
$ scala -version
Scala code runner version 2.9.1.final
Upvotes: 2