In java, common IO operations involving streams, files and the like can be somewhat annoying. Thus I (and many others) tend to reach for things like commons-io to ease the pain.
In scala - are there some better idioms/classes/libraries to use (I know of scala.io.Source etc for reading in text files - but what about streams etc). Is it "normal" to use libraries like commons-io in scala or is there a much better way?
What about using:
Source.fromInputStream(is, "UTF8")
As in:
for (line <- Source.fromInputStream(is, "UTF8").getLines) {
// process line here
}
There were some discussions on the Scala mailing list on this particular matter. And, if I recall correctly, nothing concrete came out of them. In the mean time, you won't be at a loss to check out Scalax. scalax.io looks very promising.
I/O hasn't been addressed as yet in Scala. What exists, exists solely to support the compiler and the XML library.
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