Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended Scala io library

Tags:

io

scala

By all accounts, Scala's Source is a bit of a mess - everything I've read about it mentions resources left open, mysterious bugs...

I was wondering whether that was still the case in recent versions of Scala and, if so, what are worthy alternatives?

I've mostly heard of scala-io and scalaz-streams (and, obviously standard Java IO primitives). Did I miss anything? If anyone has experience with these or other projects, what are their respective pros and cons?

I'm inclined to go for scala-io, since I found the author's blog to be a fairly high quality source of useful of information, but I'd love to know more about the alternatives and what other people use.

like image 209
Nicolas Rinaudo Avatar asked Aug 11 '13 10:08

Nicolas Rinaudo


2 Answers

Rapture IO might be worth trying.

It provides some nice DSL for managing IO resources of various kinds.

like image 140
Michał Knapik Avatar answered Sep 24 '22 21:09

Michał Knapik


Using the package java.nio.file in Java standard library may also be simple enough if you don't require advance features. For example, to read the lines of a file into memory:

Files.readAllLines(Paths.get("file_name"), StandardCharsets.UTF_8).asScala 

And to write a sequence of lines into a file:

val strs = Seq("line1", "line2", "line3") Files.write(Paths.get("output_file"), strs.mkString("\n").getBytes()) 

Check http://docs.oracle.com/javase/tutorial/essential/io/file.html for more information.

like image 38
pishen Avatar answered Sep 22 '22 21:09

pishen