Skip to content

Instantly share code, notes, and snippets.

@yoshihiro503
Last active December 12, 2015 07:38
Show Gist options
  • Save yoshihiro503/4737616 to your computer and use it in GitHub Desktop.
Save yoshihiro503/4737616 to your computer and use it in GitHub Desktop.
Scala で バイナリを読んで、Iterator[Byte]を得る方法ってどうやるのが一番いいのだろうか?
object GetBytes {
def getBytes() : Iterator[Byte] = {
val input = System.in
Iterator.continually {
val i = input.read()
if (i != -1) {
Some(i.toByte)
} else {
None
}
}.takeWhile(_.isDefined).flatten
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment