Can someone post an example of how in Jersey to set StreamingOutput
as an entity in a Response
object?
I haven't been able to find an example of this.
See if this helps:
@GET @Produces(MediaType.TEXT_PLAIN) public Response streamExample() { StreamingOutput stream = new StreamingOutput() { @Override public void write(OutputStream os) throws IOException, WebApplicationException { Writer writer = new BufferedWriter(new OutputStreamWriter(os)); writer.write("test"); writer.flush(); // <-- This is very important. Do not forget. } }; return Response.ok(stream).build(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With