downloadFilePathList = "url路径的集合"; String fileName = "test"; File zipFile = new File(fileName + ".zip"); FileOutputStream fos = null; ZipOutputStream zos = null; fos = new FileOutputStream(zipFile); zos = new ZipOutputStream(new BufferedOutputStream(fos)); for (SubscribeReport zipstream : downloadFilePathList) { BufferedInputStream bis = null; //被下载文件的路徑 URL url = new URL(imageUrl+zipstream.getUrl()); URLConnection connection = url.openConnection(); InputStream inputStream = connection.getInputStream(); String streamfileName = zipstream.getTitle()+".pdf"; byte[] bufs = new byte[1024 * 10]; // 创建ZIP实体,并添加进压缩包 ZipEntry zipEntry = new ZipEntry(streamfileName); zos.putNextEntry(zipEntry); // 读取待压缩的文件并写进压缩包里 bis = new BufferedInputStream(inputStream, 1024 * 10); int read = 0; while ((read = bis.read(bufs, 0, 1024 * 10)) != -1) { zos.write(bufs, 0, read); } bis.close(); } zos.close(); fos.close(); return zipFile;