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{ } } } }
  • 相关阅读:
    centos 7遇到的问题
    Exceptions&Files
    关于Transtion属性收藏
    游戏主循环知识积累
    display:inline、block、inline-block的区别
    Sublime text 3快捷键收藏
    业务逻辑详解随记
    探究Struts2运行机制,知识积累
    将博客搬至CSDN
    url随记
  • 原文地址:https://www.cnblogs.com/zhangxuesong/p/5671388.html
Copyright © 2011-2022 走看看