I would like to write a method similar to the following
def appendFile(fileName: String, line: String) = { }
But I'm not sure how to flesh out the implementation. Another question on here alludes to Scala 2.9 capabilities but I could not find further details.
nsc. io. File File("filename"). writeAll("hello!") // or appendAll("hello!")
There is no scala-specific IO implementation at the moment, although I understand one written by Jesse Eichar is in incubation. I'm not sure, to what extent this makes use of the new File (path) API in JDK7. Because of this, for now I would go with the simple Java:
val fw = new FileWriter("test.txt", true) try { fw.write( /* your stuff */) } finally fw.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With