zoukankan      html  css  js  c++  java
  • 生成压缩文件

    files:是所有文件的目录
    destZip:是生成压缩文件所存放的目录


    public static void zipFiles(Collection<String> files,String destZip){   FileOutputStream fout=null;   ZipOutputStream zout=null;    int len=-1;    byte[] buf=new byte[1024];   try{     FileInputStream fin=null;     fout=new FileOutputStream(destZip);     zout=new ZipOutputStream(fout);     zout.setEncoding("gbk");     for(String reportPath:files){       File repostFile= new File(reportPath);       String reportName= reportFile.getName();       ZipEntry zEntry = new ZipEntry(reportName);       zout.putNextEntry(zEntry);       fin=new FileInputStream(reportFile);     while(len=fin.read(buf))!=-1){     zout.write(buf,0,len);   }   fin.close(); } }catch(Exception e){ e.printStackTrace(); }finally{ try{ fout.close(); }catch(IOExecption e){ e.printStackTrace(); }finally{ } } } }
  • 相关阅读:
    2016.10.09
    Httpie 进行web请求模拟
    Python-集合
    python-字典
    MySQL权限系统
    MySQL8.0安装以及介绍(二进制)
    数据库对象中英文介绍
    Python-字符串
    GIT安装部署
    Cobbler安装部署
  • 原文地址:https://www.cnblogs.com/zhangxuesong/p/5671388.html
Copyright © 2011-2022 走看看