@GET
@Path("/cat-streaming-output")
@Produces("image/gif")
public StreamingOutput getRandomCatAsStreamingOutput() {
return new StreamingOutput() {
@Override
public void write(OutputStream os) throws IOException, WebApplicationException {
try (InputStream is = loadRandomCatGif()) {
byte[] buffer = new byte[BUFFER_LENGTH];
int bytesRead;
while ((bytesRead = is.read(buffer)) != -1) {
os.write(buffer, 0, bytesRead);
}
}
}
};
}
ApiResource.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:jrestless-examples
作者:
评论列表
文章目录