Scaruby is not a thin layer of java.io
but a thick layer of it. Users of Scaruby don't need to
know the detail of java.io
. Instead, Scaruby provides the way to do file I/O independently.
- Builtin loan pattern
- Simple operation can be done by simple method call
- Base64 encode/decode
- Every SReader/Swriter can be used in
for-expression
, which is implemented asforeach
method. - Support reading text/binary content from SURL
- No overloading! Instead, use type classes or default arguments
- Additional features will be added as needed
Now Scaruby supports Scala 2.11.X and Scala 2.12.X.
Add the following lines to your build.sbt:
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
libraryDependencies += "com.github.scaruby" %% "scaruby" % "0.2"
and you can use Scaruby like the following after importing the package com.github.scaruby._
:
import com.github.scaruby._
val content = SFile.read("file.txt")
import com.github.scaruby._
val input = "Hello, World!"
val encoded = SBase64.encode64(input.getBytes("UTF-8"))
val decoded = new String(SBase64.decode64(encoded), "UTF-8")
assert(input == decoded)
import com.github.scaruby._
val content = for {
r <- SURL("https://srad.jp/").openReader
} r.readAll
println(content)