Rapture I/O is a fledgling library for Scala which provides a consistent, intuitive and extensible API for handling common I/O operations, such as sending HTTP requests and streaming data between files, URLs and sockets.
Rapture I/O offers the functionality of java.io, but unifies its features into simpler, more coherent and higher-level concepts, allowing tasks which once took several lines of code to be often accomplished in just one, taking full advantage of Scala's rich syntax.
> val url = Http / "rapture.io" / "welcome.txt"
> url > File / "home" / "download"
res: Int = 53 // bytes transferred
> implicit val enc = Encodings.`UTF-8`
> (Http / "rapture.io" / "welcome.txt").slurp[Char]
res: Int = "Congratulations! ..."
> val from = Http / "rapture.io" / "doc" / "package.html"
> from link Http / "rapture.io" / "home"
res: Link = ../home
> (Http / "rapture.io" / "welcome.txt").md5Sum()
res: String = 9C0CD5E22C4B1CF0FF4ECA7042CE3463
> val url = Http / "rapture.io" / "repeat"
> url.post(Map('say -> "Hi")).slurp[Char]
res: String = "You said Hi."
> val src = (Http / "rapture.io" / "json").slurp[Char]
res: Json = "Barack Obama"
> val dir = File / "home" / "work"
res: Date = Thu Nov 15 12:00:00 GMT 2012
> Base64.encode("Hello world!")
res: String = SGVsbG8gd29ybGQh
8th April 2013
Jon Pretty will be giving a talk to the London Scala Users’ Group on Rapture I/O on 10th April.
6th March 2013
Jon Pretty will be talking about and demonstrating Rapture I/O at Scala Camp in Kraków on 20th March.
14th February 2013
Rapture I/O 0.7.2 has been released on Sonatype
21st November 2012
Video from Jon Pretty's Rapture I/O presentation at the Scala eXchange is now available!
16th November 2012
Rapture I/O version 0.7.0 has been released!
1th November 2012
Jon Pretty will be presenting Rapture I/O at the Scala eXchange 2012 in London on 19th & 20th November.
Rapture I/O is supplied as an OSGi-ready JAR file, and depends only on scala-library.jar.
Just include io.jar on your classpath,
import rapture.io._, and start using it!
Rapture I/O is now avaliable on the Sonatype OSS Repository Hosting Service. In Maven, include the dependency
<dependency> <artifactId>rapture-io</artifactId> <groupId>com.propensive</groupId> <version>0.7.2</version> </dependency>Or in SBT, add the dependency
"com.propensive" % "rapture-io" % "0.7.2".