有没有人可以在泽西岛发布一个例子,说明如何在Response
对象中将StreamingOutput
设置为实体?
我还没能找到一个这样的例子。
发布于 2012-08-18 04:39:28
看看这是否有帮助:
@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();
}
https://stackoverflow.com/questions/12012724
复制相似问题