이미지 링크를 이미지로 변환하여 압축 패키지(직접 패키징, 하위 폴더 패키징)하는 도구 클래스

public static void processImagesToZip(HttpServletResponse response, List<String> ossList) throws IOException {
		// 将 OSS 图片地址转换成图片文件
		List<File> fileList = new ArrayList<>();
		for (String ossUrl : ossList) {
			try {
				BufferedImage image = ImageIO.read(new URL(ossUrl));
				//

				String fileName = ossUrl.substring(ossUrl.lastIndexOf("/") + 1)+ UUID.randomUUID()+".jpg";
				File file = new File(fileName);
				ImageIO.write(image, "jpg", file);
				fileList.add(file);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		// 打包压缩图片文件
		File zipFile = new File("kouqiang.zip");
		try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile))) {
			byte[] buffer = new byte[1024];

			for (File file : fileList) {
				if (file.exists()) {
					ZipEntry zipEntry = new ZipEntry(file.getName());
					zipOut.putNextEntry(zipEntry);

		

추천

출처blog.csdn.net/weixin_42759398/article/details/131607769