package com.iwode.jason;
import java.io.File;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ZipExample {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
showZip("test.zip");
}
public static void showZip(String str) {
try {
// create a zip file
ZipFile zipFile = new ZipFile(str);
System.out.println("zip file:" + zipFile.getName() + ",size:"
+ zipFile.size());
// get all entries in the zip file
Enumeration en = zipFile.entries();
while (en.hasMoreElements()) {
ZipEntry entry = (ZipEntry) en.nextElement();
// if the entry is a directory
if (entry.isDirectory()) {
System.out.println("Directory:" + entry.getName());
} else {
// if the entry is a file
System.out.print("File:" + entry.getName() + ", size:"
+ entry.getSize() + ", compressedSize:"
+ entry.getCompressedSize());
File entryFile = new File(entry.getName());
System.out.println(", path:" + entryFile.getAbsolutePath());
// if you want to read the content of this file, just build
// a stream can work.
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
使用java处理zip文件
需积分: 9 198 浏览量
2008-10-08
13:08:48
上传
评论
收藏 14KB RAR 举报
RJCHEN1985
- 粉丝: 15
- 资源: 35
最新资源
- 基于MATLAB的钢板表面缺陷检测系统
- MS SQL里生成行政区域县区信息表和相应数据
- delphi实现DBGrid全选和反选功能
- 25C11F41-2B2A-4D1A-AAA8-7C654526B129.pdf
- Android Studio Jellyfish(android-studio-2023.3.1.18-cros.deb)
- MVC+EF框架+EasyUI实现权限管理源码程序
- python第66-75天,Day66-75.rar
- python后端服务project-of-tornado.rar
- python测验,hello-tornado.rar
- 基于SpringBoot+Vue3快速开发平台、自研工作流引擎源码设计.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈