我想通过scala命令行读取文本文件。 代码编译正确,但由于文件未找到错误而导致执行失败。在scala命令行中读取文本文件行
import scala.io.Source
object Mainclass extends App {
val filename = "filo.txt"
for(line <- Source.fromFile(filename).getLines) {
println(line)
}
}
这是错误:
scala Main.scala:
java.io.FileNotFoundException: filo.txt (The system cannot find the file specified)
你的代码对我来说没有错误(我创建了'filo.txt'文件之后)。 – jwvh