import scala.collection.JavaConverters._
import java.io.{ByteArrayInputStream, InputStream, SequenceInputStream}
val strings: Iterator[String] = ???
val stream: InputStream = new SequenceInputStream({
val i = strings map { s => new ByteArrayInputStream(s.getBytes("UTF-8")) }
i.asJavaEnumeration
})
Betreff: [scala-user] Iterator to inputstream
Hello,
I want to convert an Iterator[String] to a java.io.InputStream but I didn't find an east way to do it.
The main challenge is I cannot store all the data in memory to say, creating the inputstream from the array of byte or something like that, it needs to be lazy.
Currently I am saving the iterator as temporary file and then opening an inputstream on the file.
Does anybody know a better way to do that ?
If the scala API can't do that kind of transformation, is there a library that would allow to do that ?
Thanks,
Ayoub.--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--