批量打包下载

时间:2016-08-27 10:52:48
【文件属性】:

文件名称:批量打包下载

文件大小:2KB

文件格式:RAR

更新时间:2016-08-27 10:52:48

java 批量下载

批量打包下载.txt /** * 文件下载 * @param response * @param str */ private void downFile(HttpServletResponse response, String str) { try { //String FilePath = "D:\\"; String FilePath = "\\D:\\apache-tomcat-6.0.29\\webapps\\js-edu\\"; String path = FilePath + str; File file = new File(path); if (file.exists()) { InputStream ins = new FileInputStream(path); BufferedInputStream bins = new BufferedInputStream(ins);// 放到缓冲流里面 OutputStream outs = response.getOutputStream();// 获取文件输出IO流 BufferedOutputStream bouts = new BufferedOutputStream(outs); response.setContentType("application/x-download");// 设置response内容的类型 response.setHeader( "Content-disposition", "attachment;filename=" + URLEncoder.encode(str, "UTF-8"));// 设置头部信息 int bytesRead = 0; byte[] buffer = new byte[8192]; // 开始向网络传输文件流


【文件预览】:
批量打包下载.txt

网友评论