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;  

           }

    }

  • 相关阅读:
    linux查看公网ip的方法
    统计文件或文件夹个数
    python manage.py shell
    炒冷饭,对于数据库“删除”操作大家平时都是物理删除,还是逻辑删除啊?
    SQL表名,应该用表对应资源对象的复数形式还是单数形式
    git常用命令
    Django ORM中的模糊查询
    threading 学习笔记
    class类笔记整理
    函数笔记整理
  • 原文地址:https://www.cnblogs.com/lxaic/p/4990711.html
Copyright © 2011-2022 走看看