java实现文件下载两种方式(一)
前端直接超链接即可,修改文件类型需修改contenttype中的类型
public void export(HttpServletResponse response) throws IOException {
File f=new File("文件路径");
response.reset();
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition","attachment; filename="+System.currentTimeMillis()+".txt");
OutputStream out=response.getOutputStream();
workbook.write(out);
out.flush();
out.close();
}`