返回文件流
public void downloadFloodInfo(HttpServletRequest request, HttpServletResponse response) {
String fileAllPath = "/xxxxxx/xxx/xxx.xxx";
File file = new File(fileAllPath);
if (file == null) {
try {
response.sendError(404, "文件不存在!");
return;
} catch (IOException e) {
e.printStackTrace();
}
}
try (
FileInputStream fileInputStream = new FileInputStream(new File(fileAllPath));
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
ServletOutputStream outputStream = response.getOutputStream();
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
) {
// 设置response的Header
response.setCharacterEncoding("utf-8");
respons