java不解压zip文件时,获取其中的文件
来源:互联网 发布:卧龙大数据技术总监 编辑:程序博客网 时间:2024/04/30 15:14
直接上代码
public static void unzip(InputStream ins, String targetFile) {
BufferedOutputStream dest = null;
ZipEntry entry;
ZipInputStream zin = null;
FileOutputStream fos = null;
try {
zin = new ZipInputStream(new BufferedInputStream(ins));
while ((entry = zin.getNextEntry()) != null) {
//判断是否是目录
if(!entry.isDirectory()){
System.out.println("Extracting: " + entry);
int count;
byte data[] = new byte[BUFFER];
String filePath = targetFile + "/" + entry.getName();
String path = filePath.substring(0, filePath.lastIndexOf("/"));
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
System.out.println("图片名称=entry===" + entry);
System.out.println("图片名称=entry.getName()===" + entry.getName());
System.out.println("图片名称=entry.getName().toLowerCase()===" + entry.getName().toLowerCase());
// fos = new FileOutputStream(targetFile + "/"
// + entry.getName().toLowerCase());
String picName = entry.getName().substring(entry.getName().indexOf("/")+1);
System.out.println("图片名称=picName===" + picName);
fos = new FileOutputStream(targetFile + "/" + picName);
dest = new BufferedOutputStream(fos, BUFFER);
while ((count = zin.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
}
}
zin.close();
fos.flush();
fos.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (dest != null) {
dest.close();
}
if (zin != null) {
zin.close();
}
if (fos != null) {
fos.close();
}
} catch (Exception e) {
}
}
}
- java不解压zip文件时,获取其中的文件
- Java解压zip文件
- zip解压文件java
- java-zip解压文件
- JAVA解压ZIP文件
- Java解压zip文件
- java-解压zip文件
- java--解压zip文件
- java 解压zip文件
- JAVA解压ZIP文件
- java解压zip文件
- java 解压zip文件
- 解压*.zip.*的文件
- java zip文件的压缩与解压
- 使用java实现zip文件的解压
- java解压带密码的zip文件
- Java解决Zip文件的解压
- 不解压tar.gz文件查看其中的文件大小
- iOS UISplitViewController 使用教学
- css3动画模块transform transition animation属性解释
- JSP中application session request cookie 生命周期的问题
- $().each和$.each()的区别
- QPBOC交易流程详解--POS与卡片的数据交互进行分析
- java不解压zip文件时,获取其中的文件
- ios---CocoaPods的安装使用和常见问题
- 【软考】---计算机存储系统
- 获取手机屏幕宽高
- windows 安装easy_installm命令和pip命令
- MEF 打造的插件系统
- js清除浏览器缓存的几种方法
- 3709: Number Maze
- Efficiently Implementing Dilate and Erode Image Functions