zoukankan      html  css  js  c++  java
  • 文件压缩和解压缩工具类

    public class ZipHelper {  

              public static void compress(InputStream is, OutputStream os, String entry) throws Exception{

                            byte[] bytes = new byte[1024 * 8];

                            ZipOutputStream zos = new ZipOutputStream(os);

                            if(entry != null)    zos.putNextEntry(new ZipEntry(entry));

                            int count = 0;  

                            while((count = is.read(bytes)) > 0){    

                                      zos.write(bytes,0,count);  

                            }      

                            zos.flush();   

                            zos.close();  

               }

              public static ByteArrayOutputStream decompression(ZipInputStream zis) throws Exception{

                           ByteArrayOutputStream bos = new ByteArrayOutputStream();

                           byte[] bytes = new byte[1024 * 8];   

                           while(zis.getNextEntry() != null){   

                                   int count = 0;    

                                   while((count = zis.read(bytes)) > 0){     

                                             bos.write(bytes,0,count);  

                                   } 

                           }

                           return bos;  

           }

    }

  • 相关阅读:
    ES中对应的SQL的count(distinct 列名) java实现
    maven使用
    自旋锁
    Java手写死锁并用jps和jstack查看
    已知二叉树前序和中序,算法写出后续遍历的结果
    Idea里搭建SpringMVC项目,部署的包下没有lib
    Spring配置文件中关于bean标签的id属性和name属性的说明
    ORA-12519: TNS:no appropriate service handler found 解决
    springmvc常用注解标签详解
    Spring/SpringMvc 配置文件常用标签解释
  • 原文地址:https://www.cnblogs.com/lxaic/p/4990711.html
Copyright © 2011-2022 走看看