write bytes to file in scala
val byteArray: Array[Byte] = Array(1,2) val bos = new BufferedOutputStream(new FileOutputStream(filename)) Stream.continually(bos.write(byteArray)) bos.close() // You may end up with 0 bytes file if not calling close.