Access Segment Of Input

Examples for reading sections of an Input object without reading all data in the underlying resource

Taking Bytes

How to close resource after reading first X bytes
    import scalax.io._

    val in:Input = Resource.fromURLString("file://someFile")

    // Take first 10 bytes then close resource.
    // Remember the resource is lazy so firstTenBytes is not
    // an in-memory collection and accessing it will open
    // the resource and read the data.  At the moment of
    // ''firstTenBytes'' the resource has not been opened.
    val firstTen = in.bytesAsInts.take(10)

    // This statement will open resource take first 10 bytes add
    // them together and close resource.
    val sum = firstTen.reduceLeft(_ + _)