标签:
@RequestMapping("/pluginDownload") public void pluginDownload(HttpServletResponse response) throws FileNotFoundException { // 下载本地文件 String fileName = "plugin.rar"; // 读到流中 InputStream inStream = new FileInputStream("d:/up_pipegis/plugin/plugin.rar"); // 设置输出的格式 response.reset(); response.setContentType("bin"); response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); // 循环取出流中的数据 byte[] b = new byte[128]; int len; try { while ((len = inStream.read(b)) > 0) response.getOutputStream().write(b, 0, len); inStream.close(); } catch (IOException e) { e.printStackTrace(); } }
标签:
原文地址:http://www.cnblogs.com/vvonline/p/4323327.html