File input/output: Difference between revisions
Content deleted Content added
→{{header|Scala}}: Exception-handling added |
|||
Line 1,877: | Line 1,877: | ||
[[Category:Scala Implementations]] |
[[Category:Scala Implementations]] |
||
{{libheader|Scala}} |
{{libheader|Scala}} |
||
<lang scala>import java.io.PrintWriter |
<lang scala>import java.io.{ FileNotFoundException, PrintWriter } |
||
object FileIO extends App { |
object FileIO extends App { |
||
try { |
|||
⚫ | |||
val MyFileTxtTarget = new PrintWriter("output.txt") |
|||
⚫ | |||
⚫ | |||
MyFileTxtTarget.print(str) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
MyFileTxtTarget.print(str) |
|||
} |
|||
} catch { |
|||
⚫ | |||
case e: FileNotFoundException => println(e.getLocalizedMessage()) |
|||
⚫ | |||
} |
|||
}</lang> |
}</lang> |
||