我有一个InputStream,想要将其写入HttpServletResponse。有一种方法可以实现,但由于使用了byte[],速度太慢了。
InputStream is = getInputStream();
int contentLength = getContentLength();
byte[] data = new byte[contentLength];
is.read(data);
//response here is the HttpServletResponse object
response.setContentLength(contentLength);
response.write(data);
我在想,在速度和效率方面,可能有什么最好的方法可以实现它。