With Scala, what is the best way to read from an InputStream to a bytearray?
I can see that you can convert an InputStream to char array
Source.fromInput
How about:
Stream.continually(is.read).takeWhile(_ != -1).map(_.toByte).toArray
Update: Use LazyList instead of Stream (since 2.13.x deprecated)
Use LazyList instead of Stream
LazyList.continually(is.read).takeWhile(_ != -1).map(_.toByte).toArray