Created
February 19, 2012 16:22
-
-
Save machisuji/1864504 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val in: InputStream | |
val buffer: Array[Byte] | |
val stream: Stream[Array[Byte]] = | |
Stream.continually(in.read(buffer)).takeWhile(-1 !=).map(buffer take) | |
val iterator: Iterator[Array[Byte]] = | |
Iterator.continually(in.read(buffer)).takeWhile(-1 !=).map(buffer take) | |
stream.foreach(println) // the byte arrays stay | |
iterator.foreach(println) // the byte arrays go (some time) | |
// run on forever |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment