设为首页 加入收藏

TOP

Java程序实现压缩某目录
2014-10-30 17:30:06 】 浏览:342
Tags:Java 程序 实现 压缩 目录

  public class TestZip {


  public static String SERPEROT = "/";


  public static int BUFFER = 2048;


  public static void main(String args[]){


  zip("e:/hello/", "e:/hello.zip");


  }


  public static void zip(String srcFile, String descFile){


  ZipOutputStream zos = null;


  FileOutputStream fos = null;


  File file = null;


  try {


  fos = new FileOutputStream(descFile);


  zos = new ZipOutputStream(fos);


  file = new File(srcFile);


  String folder = srcFile.substring(srcFile.lastIndexOf("/") +1,srcFile.length());


  zip(zos,file,folder);


  } catch (FileNotFoundException e) {


  e.printStackTrace();


  }finally{


  try{


  if(zos != null){zos.close();}


  if(fos != null){fos.close();}


  }catch(Exception e){


  e.printStackTrace();


  }


  }


  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇JBuilder9制作EXE文件 下一篇Java中使用密钥库和算法创建数字..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目