Chinaunix首页 | 论坛 | 博客
  • 博客访问: 46217
  • 博文数量: 26
  • 博客积分: 609
  • 博客等级: 准尉
  • 技术积分: 290
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-14 09:02
文章分类
文章存档

2010年(26)

最近访客

分类:

2010-08-10 15:02:02

/**
 * 解压zip文件
 *
 * @param sourceFile,待解压的zip文件;
 *            toFolder,解压后的存放路径
 * @throws Exception
 */
/*
 * public static void zipToFile(String sourceFile, String toFolder) throws
 * Exception {
 *
 * String toDisk = toFolder;//接收解压后的存放路径 ZipFile zfile = new
 * ZipFile(sourceFile);//连接待解压文件 System.out.println("要解压的文件是:" +
 * zfile.getName());
 *
 * Enumeration zList = zfile.entries();//得到zip包里的所有元素 ZipEntry ze = null; byte[]
 * buf = new byte[1024];
 *
 * while (zList.hasMoreElements()) { ze = (ZipEntry) zList.nextElement(); if
 * (ze.isDirectory()) { System.out.println("打开zip文件里的文件夹:" + ze.getName() + "
 * skipped..."); continue; } System.out.println("zip包里的文件: " + ze.getName() +
 * "\t" + "大小为:" + ze.getSize() + "KB");
 *
 * //以ZipEntry为参数得到一个InputStream,并写到OutputStream中 OutputStream outputStream =
 * new BufferedOutputStream( new FileOutputStream(getRealFileName(toDisk,
 * ze.getName()))); InputStream inputStream = new BufferedInputStream(zfile
 * .getInputStream(ze)); int readLen = 0; while ((readLen =
 * inputStream.read(buf, 0, 1024)) != -1) { outputStream.write(buf, 0, readLen); }
 * inputStream.close(); outputStream.close(); System.out.println("已经解压出:" +
 * ze.getName()); } zfile.close(); }
 */
/*
 * private void startIMP(StringBuffer msg) { File srcFilePath = new
 * File(Util.getResourceString("srcFilePath"));
 *
 * File[] srcFiles = srcFilePath.listFiles(); //
 *
 * if (srcFiles.length > 0) { for (int i = 0; i < srcFiles.length; i++) { File
 * file = srcFiles[i]; try { if(file.isFile()){ //doOneFile(file,msg); } } catch
 * (AppException e) {
 *
 * e.printStackTrace(); } } } }
 */
阅读(629) | 评论(0) | 转发(0) |
0

上一篇:usefull sites

下一篇:Work

给主人留下些什么吧!~~