Access Segment Of Input
Examples for reading sections of an Input object without reading all data in the underlying resource
Take While
How to take bytes until a condition is met and then close resource
import scalax.io._
val in:Input = Resource.fromURLString("file://someFile")
// take bytes until they one is greater than 5
// Note: bytes is a view which means it does not open the
// resource until the actual data is requested.
// The following statement does not access resource
val lessThan5 = in.bytesAsInts.takeWhile(_ < 5)
// This statement will open resource take add
// bytes together (until a byte greater than 5)
// and close resource.
val sum = lessThan5.reduceLeft(_ + _)