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{ } } } }
  • 相关阅读:
    Java修饰符
    java中接口的定义
    抽象类
    final关键字的特点
    hdu6489 2018 黑龙江省大学生程序设计竞赛j题
    POJ 3268 (dijkstra变形)
    poj 2253 floyd最短路
    poj1681 Network
    bzoj1202 狡猾的商人
    Nastya Is Buying Lunch
  • 原文地址:https://www.cnblogs.com/zhangxuesong/p/5671388.html
Copyright © 2011-2022 走看看