If you don't mind a third-party dependency, you should consider using my OS-Lib library. This makes reading/writing files and working with the filesystem very convenient:
// Make sure working directory exists and is emptyval wd = os.pwd/"out"/"splash"os.remove.all(wd)os.makeDir.all(wd)// Read/write filesos.write(wd/"file.txt", "hello")os.read(wd/"file.txt") ==> "hello"// Perform filesystem operationsos.copy(wd/"file.txt", wd/"copied.txt")os.list(wd) ==> Seq(wd/"copied.txt", wd/"file.txt")
with one-line helpers for reading bytes, reading chunks, reading lines, and many other useful/common operations