2013-10-27 22:24:23 +00:00
|
|
|
import java.io.{ FileNotFoundException, PrintWriter }
|
2013-04-10 21:29:02 -07:00
|
|
|
|
2013-10-27 22:24:23 +00:00
|
|
|
object FileIO extends App {
|
|
|
|
|
try {
|
|
|
|
|
val MyFileTxtTarget = new PrintWriter("output.txt")
|
2013-04-10 21:29:02 -07:00
|
|
|
|
2015-02-20 09:02:09 -05:00
|
|
|
scala.io.Source.fromFile("input.txt").getLines().foreach(MyFileTxtTarget.println)
|
2013-10-27 22:24:23 +00:00
|
|
|
MyFileTxtTarget.close()
|
|
|
|
|
} catch {
|
|
|
|
|
case e: FileNotFoundException => println(e.getLocalizedMessage())
|
|
|
|
|
case e: Throwable => {
|
|
|
|
|
println("Some other exception type:")
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|