ZipInputStream使用
来源:互联网 发布:潮汕话学习软件 编辑:程序博客网 时间:2024/05/16 00:44
ZipInputStream使用代码如下:
package cn.lfsenior.zipout;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.util.zip.ZipEntry;import java.util.zip.ZipInputStream;public class Decompression { public static void main(String[] args) { ZipInputStream zin; try { //创建你要解压的文件的File对象 File file_base=new File("E:\\hello.zip"); //获取解压的目标路径的基础目录 String path_base=file_base.getParent()+"\\"+file_base.getName().subSequence(0, file_base.getName().indexOf(".zip")); //创建ZipInputStream对象 zin=new ZipInputStream(new FileInputStream(file_base)); //获取下一个ZinpEntry。这里获取一次是因为zip文件本身有一个“/”的ZipEntry对象,是使用不到的 ZipEntry entry=zin.getNextEntry(); while((entry=zin.getNextEntry())!=null){ //创建文件对对象 File file=new File(path_base+"\\"+entry.getName()); System.out.println(file); //判断是否是文件夹 if(entry.isDirectory()){ //是创建文件夹 file.mkdirs(); }else{ //不是创建文件 if(!file.exists()){ file.createNewFile(); } } //关闭当前entry zin.closeEntry(); System.out.println(entry.getName()+"解压成功"); } zin.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}
0 0
- ZipInputStream使用
- 【记录】使用 ZipInputStream类getNextEntry方法遇到的错误
- zipInputStream 应用
- ZipInputStream类
- ZipInputStream & ZipOutputStream
- [Java语言] java 中使用ZipInputStream或ZipFile解压ZIP文件!!
- 使用JAVA自带的zipInputStream进行解压缩文件包的操作
- ZipOutputStream 和 ZipInputStream 例子
- Java IO操作——掌握压缩流的使用(ZipOutputStream、ZipFile、ZipInputStream)[java.util包中]
- java.util.zip.ZipInputStream翻译
- java 解zip文件(ZipInputStream)
- java语言SDK中ZipInputStream
- 压缩解压缩工具 ZipInputStream ZipOutputStream
- java.util.zip类 ZipInputStream
- 解决ZipInputStream不能正确处理中文文件名
- 让ZipOutputStream和ZipInputStream支持中文
- Java IO 之 ZipFile/ZipInputStream/ZipOutputStream
- deflate and inflate simple demo (ZipInputStream/ZipOutputStream)
- ASP.Net 防止重复登录
- [kuangbin带你飞]专题四 最短路练习H,I,J
- win下RPC编程小tips1-error编码含义
- Java编程思想笔记——第二章 一切都是对象
- heap&stack 区别
- ZipInputStream使用
- 109. Convert Sorted List to Binary Search Tree
- php7.0.13 pdo无法开启问题
- 快速排序
- Unity3D小游戏 - BallGame安卓打包
- 死锁与预防措施
- jenkins+maven+junit构建自动化测试,整合junit xml生成直观的测试报告
- Julia: Array过滤
- 一个简单的计算器(Java)