Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/File-input-output/Scala/file-input-output.scala
Normal file
16
Task/File-input-output/Scala/file-input-output.scala
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import java.io.{ FileNotFoundException, PrintWriter }
|
||||
|
||||
object FileIO extends App {
|
||||
try {
|
||||
val MyFileTxtTarget = new PrintWriter("output.txt")
|
||||
|
||||
scala.io.Source.fromFile("input.txt").getLines().foreach(MyFileTxtTarget.println)
|
||||
MyFileTxtTarget.close()
|
||||
} catch {
|
||||
case e: FileNotFoundException => println(e.getLocalizedMessage())
|
||||
case e: Throwable => {
|
||||
println("Some other exception type:")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue