How to create a Vert.x ReadStream from an InputStream

Viewed 934

I would like to stream the stdout of a local process to a Vert.x HttpResponse.

To do it I think I have to stream/convert/pipe a java.io.InputStream (which streams the process stdout) to an io.vertx.core.streams.ReadStream and then I can pipe the ReadStream to the HttpResponse.

I'm searching for a solution that has a small memory impact, so read the whole stdout in memory and then flush it to the HttpResponse is not possible.

Thanks

2 Answers

Another way is to use the OutputToReadStream class from the vertx-java.io library (I am the author):

new OutputToReadStream(vertx).wrap(inputStream).pipeTo(response);
Related