博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZipUtils
阅读量:4691 次
发布时间:2019-06-09

本文共 1234 字,大约阅读时间需要 4 分钟。

 

package com.icil.elsardcservice.untils;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.io.InputStream;import java.util.zip.ZipEntry;import java.util.zip.ZipOutputStream;/** * @Author: sea * @Description: * @Date:Created in 下午8:31 19-5-18 * @Modified By: */public class ZipUtils {    public static void compressFileToZip(InputStream inputStream, ZipOutputStream zipOutputStream, String name) {        try {            ZipEntry zipEntry = new ZipEntry(name);            zipOutputStream.putNextEntry(zipEntry);            int len;            byte[] bytes = new byte[1024];            while ((len = inputStream.read(bytes)) != -1) {                zipOutputStream.write(bytes, 0, len);                zipOutputStream.flush();            }        } catch (IOException e) {            e.printStackTrace();        } finally {            try {                if (zipOutputStream != null) {                    zipOutputStream.closeEntry();                }                if (inputStream != null) {                    inputStream.close();                }            } catch (IOException e) {                e.printStackTrace();            }        }    }}

 

转载于:https://www.cnblogs.com/lshan/p/10894228.html

你可能感兴趣的文章
不把DB放进容器的理由
查看>>
OnePage收集
查看>>
Java parseInt()方法
查看>>
yahoo的30条优化规则
查看>>
[CCF2015.09]题解
查看>>
[NYIST15]括号匹配(二)(区间dp)
查看>>
json_value.cpp : fatal error C1083: 无法打开编译器生成的文件:No such file or directory
查看>>
洛谷 P1101 单词方阵
查看>>
Swift DispatchQueue
查看>>
C#和JAVA 访问修饰符
查看>>
集合框架
查看>>
小甲鱼OD学习第1讲
查看>>
【转】简述生成式对抗网络
查看>>
HDU-1085 Holding Bin-Laden Captive-母函数
查看>>
php提示undefined index的几种解决方法
查看>>
轻量级原生 ajax 函数,支持 get/array post/array post/json
查看>>
LRJ
查看>>
Struts2环境搭建
查看>>
Linux: Check version info
查看>>
Javascript-正则表达式-开发中的使用.
查看>>