File input/output: Difference between revisions
Content added Content deleted
(→{{header|Scala}}: Exception-handling added) |
|||
Line 1,889: | Line 1,889: | ||
MyFileTxtTarget.close() |
MyFileTxtTarget.close() |
||
MyFileTxtSource.close() |
MyFileTxtSource.close() |
||
scala.io.Source.fromFile("output.txt").getLines().foreach { |
|||
line => println(line) |
|||
} |
} |
||
} catch { |
} catch { |
||
case e: FileNotFoundException => println(e.getLocalizedMessage()) |
case e: FileNotFoundException => println(e.getLocalizedMessage()) |
||
case e: Throwable => { |
|||
println("Some other exception type:") |
|||
e.printStackTrace() |
|||
} |
|||
} |
} |
||
}</lang> |
}</lang> |