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;  

           }

    }

  • 相关阅读:
    预处理器宏指令(Macro)
    汇编语言中macro的用法
    USB设备的VID与PID
    前端工具 | JS编译器Monaco使用教程
    vue + ts中的shimsvue.d.ts文件的作用,在ts中引入vueecharts等vue文件 TypeScript 导入 JSON Module resolveJsonModule
    Jenkins自动打包并部署到远程服务器
    如何获取设备的VID,PID?
    TypeScript装饰器(decorators)
    MACRO指令
    IE6左右边框断线现象
  • 原文地址:https://www.cnblogs.com/lxaic/p/4990711.html
Copyright © 2011-2022 走看看