// 输入流,通过输入流读取文件内容
// InputStream fileInputStream = new FileInputStream(new File(basePath+fileById.getCurrentFileName()));
// InputStream fis = new BufferedInputStream(fileInputStream);
// byte[] buffer = new byte[fis.available()];
// fis.read(buffer);
// fis.close();
// response.reset();
// response.setCharacterEncoding("UTF-8");
// response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileById.getCurrentFileName(), "UTF-8"));
// response.addHeader("Content-Length", "" + fileById.getFileSize());
// OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
// response.setContentType("application/octet-stream");
// outputStream.write(buffer);
// outputStream.flush();
// fileInputStream.close();
Java 浏览器下载文件
最新推荐文章于 2024-07-18 10:59:44 发布