@GetMapping(value = "downloadFile",produces = "text/plain;charset=UTF-8")
public void downloadFile(HttpServletResponse response, String path) throws IOException {
String fileName = path.substring(path.lastIndexOf("."),path.length());
InputStream fileInputStream = new FileInputStream(path);
OutputStream outputStream = response.getOutputStream();
response.reset();
response.setContentType("application/octet-stream");
response.addHeader("Content-Disposition","attachment; filename= " + FileUtils.getNowTime()+fileName + "");
byte[] b = new byte[1024];
int len = 0;
try {
while ((len = fileInputStream.read(b)) > 0){
outputStream.write(b,0,len);
}
fileInputStream.close();
outputStream.close();
}catch (Exception e){
System.out.println("下载失败");
e.printStackTrace();
}
}