Basic Read Write

These examples are a quick introduction to performing basic IO using the Scala IO API

Load Into Memory

quickly (and unsafely) load all data into memory

    // first load as strings and remove vowels
    import scalax.io._
    import Resource._
    import java.net.URL
    import java.io.InputStream

    // see codec examples in scala io core for details on why there is an implicit codec here
    implicit val codec = scalax.io.Codec.UTF8

    val url: InputStreamResource[InputStream] = fromURLString("http://www.scala-lang.org")
    // You can convert an InputStreamResource to a _ReadChars_ type if desired.  That means that the codec needs to be
    // defined just once.
    val someReader: ReadChars = url.reader(Codec.UTF8)
    val consonants = url.slurpString.filterNot (c => "aeiou" contains c)

    // ok now as bytes
    val (small, large) = url.byteArray partition (_ < 128)