有人可以发布一个如何在Jersey中设置StreamingOutput为Response对象中的实体的示例吗?
我无法找到这样的例子.
con*_*dit 120
看看这是否有帮助:
@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();
}
| 归档时间: | 
 | 
| 查看次数: | 54467 次 | 
| 最近记录: |