• ZipUtils


    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();
                }
            }
        }
    }
  • 相关阅读:
    bean的作用域和生命周期
    装配Bean的三种方式
    BeanFactory和ApplicationContext对比
    创建 Spring容器的三种方式
    约束
    三大范式
    事务
    EdgeRank
    TCP三次握手四次挥手
    Linux权限解释
  • 原文地址:https://www.cnblogs.com/lshan/p/10894228.html
Copyright © 2020-2023  润新知