Most effective way to write File to ServletOutputStream

后端 未结 4 578
不思量自难忘°
不思量自难忘° 2020-12-14 21:19
ServletOutputStream output = response.getOutputStream();
output.write(byte[]);

What is the most effective way to write File to javax.servlet.Servle

4条回答
  •  遥遥无期
    2020-12-14 21:30

    IOUtils.copy(in, out);
    out.flush();
    //...........
    out.close(); // depends on your application
    

    Where in is the FileInputStream and out is the SocketOutputStream. IOUtils is a utility from Commons IO module in Apache Commons.

提交回复
热议问题