public static void exportZip(HttpServletResponse response,File File) {
try {
String filepath = File.getPath();
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(File.getName(), "UTF-8"));
File f = new File(filepath);
byte[] buff = new byte[(int) f.length()];
new FileInputStream(filepath).read(buff);
response.getOutputStream().write(buff);
} catch (Exception e) {
e.printStackTrace();
}
}
下载文件(文件地址可选)
最新推荐文章于 2024-04-14 11:45:00 发布