运用JDK中 ZipInputStream类实现压缩文件的解压缩功能
来源:互联网 发布:重庆时时彩平台源码 编辑:程序博客网 时间:2024/04/29 10:12
将压缩文件log.zip 解压到output文件夹:
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.util.zip.ZipEntry;
- import java.util.zip.ZipInputStream;
- public class UnZipExample {
- public static void main(String[] args) {
- String zipFile = "log.zip";
- String outputFolder = "output";
- byte[] buffer = new byte[1024];
- try {
- File folder = new File(outputFolder);
- if (!folder.exists()) {
- folder.mkdir();
- }
- //获取zip文件
- ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile));
- //获取zip文件里面的文件列表
- ZipEntry ze = zis.getNextEntry();
- while (ze != null) {
- String fileName = ze.getName();
- File newFile = new File(outputFolder + File.separator + fileName);
- System.out.println("文件解压 : " + newFile.getAbsoluteFile());
- //获取文件名中的路径创建文件夹
- new File(newFile.getParent()).mkdirs();
- FileOutputStream fos = new FileOutputStream(newFile);
- int len;
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- fos.close();
- ze = zis.getNextEntry();
- }
- zis.closeEntry();
- zis.close();
- System.out.println("End");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- }
- 运用JDK中 ZipInputStream类实现压缩文件的解压缩功能
- Android平台中实现Zip文件的解压缩功能
- 常见压缩文件的解压缩方法
- xz压缩文件的解压缩过程
- java实现解压缩(Unzip)功能的实现
- 压缩解压缩工具 ZipInputStream ZipOutputStream
- ZipInputStream类
- 怎么实现MindMapper中过滤功能的运用
- 解压缩文件和压缩文件的方法
- Java 解压缩 zip格式的压缩文件
- 另存网站模版时发生的错误:从压缩文件中解压缩数据失败
- 使用JAVA自带的zipInputStream进行解压缩文件包的操作
- 高效的运用MAP类实现“比较”的功能
- php实现zip压缩文件解压缩代码分享(简单易懂)
- 解压缩文件(压缩文件中有一个文件)
- linux中rar文件解压缩的实现
- 在java中实现zip压缩文件的具体实现
- 在线解压缩 压缩文件
- Android Application 对象介绍
- Java汉字转拼音pinyin4j用法
- 黄淮学院CSDN高校俱乐部举行户外趣味活动
- 趣味编程题——猜算式
- android 保存具有不同前缀的同一号码分别为A和B,用其中一个呼叫,通话记录一直显示另一个联系人名字的问题
- 运用JDK中 ZipInputStream类实现压缩文件的解压缩功能
- Installation error: INSTALL_FAILED_VERSION_DOWNGRADE
- 第一章 自己动手写第一个最小的“操作系统”
- InitCommonControlsEx调用失败,manifest作怪
- 安装.NET Framework 3.5 SP1 超慢的解决办法
- Ganymed_ssh2工具bug
- Duilib中各个类的简单介绍
- git 服务器搭建若干问题
- IE 下的各种浏览器模式的区别