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
Here's an approach using scalaz-stream:
import scalaz.concurrent.Task import scalaz.stream._ import scodec.bits.ByteVector def allBytesR(is: InputStream): Process[Task, ByteVector] = io.chunkR(is).evalMap(_(4096)).reduce(_ ++ _).lastOr(ByteVector.empty)