I had look here which has nice answer on how to use JAX-RS StreamingOutput, but I think this StreamingOutput has the draw back it can stream the data only when we execute following code
StreamingOutput output; // do processing StreamingOutput streamOut = null;
if (outStream != null) {
final String strStream = outStream.toString();
streamOut = new StreamingOutput() {
@Override
public void write(OutputStream os) throws IOException, WebApplicationException {
Writer writer = new BufferedWriter(new OutputStreamWriter(os));
writer.write(strStream);
writer.flush();
}
};
} if (output != null)
return Response.ok(new MultiPart(MULTIPART_MIXED_TYPE).bodyPart(jobInstance, MediaType.APPLICATION_JSON_TYPE)
.bodyPart(output, MediaType.TEXT_PLAIN_TYPE)).build();
I am thinking of useing Response getOutputStream instead of StreamingOutput in JAX-RS class. can any body please explain on this ?