| | |
| | | public void download(String fileids, HttpServletRequest request, HttpServletResponse response) { |
| | | String[] arr = fileids.split(","); |
| | | List<File> files = new ArrayList<>(); |
| | | List<String> fileName = new ArrayList<>(); |
| | | Arrays.stream(arr).forEach(i -> { |
| | | FilesUpload filesUpload = this.getById(i); |
| | | files.add(new File(properties.getUploadPpath() + filesUpload.getFilesaddress())); |
| | | fileName.add(filesUpload.getFilesname()); |
| | | }); |
| | | //设置压缩包的名字 |
| | | //解决不同浏览器压缩包名字含有中文时乱码的问题 |
| | |
| | | try { |
| | | //添加ZipEntry,并ZipEntry中写入文件流 |
| | | //这里,加上i是防止要下载的文件有重名的导致下载失败 |
| | | zipos.putNextEntry(new ZipEntry(file.getName())); |
| | | zipos.putNextEntry(new ZipEntry(fileName.get(i))); |
| | | os = new DataOutputStream(zipos); |
| | | InputStream is = new FileInputStream(file); |
| | | byte[] b = new byte[100]; |