Coming from a C/C++ background, I\'m not very familiar with the functional style of programming so all my code tends to be very imperative, as in most cases I just can\'t se
To add how the same can be achieved using the formerly new nio
files which I vote to use because it has several advantages:
val path: Path = Paths.get("foo.txt")
val lines = Source.fromInputStream(Files.newInputStream(path)).getLines()
// Now we can iterate the file or do anything we want,
// e.g. using functional operations such as map. Or simply concatenate.
val result = lines.mkString
Don't forget to close the stream afterwards.