开发者

Guide to scala.io and simple IO for Scala 2.9?

Does anybody have a guide to this, containing code samples, tips and an outline of the different IO approaches?

I have checked out the the API documentation. There are also some basic examples with scala.io.Source in Programming in Scala.

There are some pretty basic questions already answered here on SO.

I'm looking for something more in d开发者_如何学Goepth.

Alternatively, any tips on exactly which bits of the API documentation to focus on and which Java libraries? I'm familiar with System.IO in .NET land, but not so much Java.


Scala's standard library is currently pretty limited for I/O, so you'll probably want to dig into Java's libraries. Oracle's Basic I/O tutorial, covering java.nio, looks like a reasonable starting point.

A while ago there was some discussion about a community driven redesign of Scala I/O called scala-io, but I'm not sure the official status. The mailing list hasn't seen much recent activity, but the code in Github is being actively developed (incubator mailing list and Github project). In his answer, hishadow gave a link to scala-io documentation.


My tip is to look also at tools Path,File and Directory.

They have little sugar (that everyone has in their little utils library) like:

val writer = File("/my/file").bufferedWriter
File.closeQuietly(writer)
Directory("myDir").walk

Then have a look at Process like here


There is an in-development IO library with documentation available at http://jesseeichar.github.com/scala-io/. Included are examples for different usages.

The source repository is at https://github.com/jesseeichar/scala-io.


I recommend looking at java.nio.

Due to technical limitations of the underlying Java platform implementing IO in Scala wasn't a good idea.

This has changed with Java 7, which provides good Java APIs for everything related to file management.

There are some thoughts about an IO library for Scala, but no decision about that yet.


The author of scala-IO, Jesse Eichar, has recently began a series of articles about using Scala-IO on his blog: here's the 'getting started' entry.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜