使用truezip解压缩zip文件
来源:互联网 发布:易语言e4a源码 编辑:程序博客网 时间:2024/05/17 08:27
/**
* 解压缩zip包
*
* @param zipfile
* zip包
* @param unzippath
* 解压缩的目標路径
* @return
*/
public static String unziptopath(File zipfile, String unzippath) throws AppException {
File localfile = null;
try {
String xmlpath = "";
localfile = zipfile;
FileOutputStream fout = null; // 解压文件输出流
byte[] buf = new byte[1024];
ZipFile zip = new ZipFile(localfile, "GBK"); // 取出zip文件
String zipname = localfile.getName(); // 获得zip包name
String zipRealName =FileUtility.removeExtension(FileUtility.removePath(zipname));//zipname.substring(begin, end); // 取得zip包去掉路径和后缀名的name
Enumeration zList = zip.entries();// 返回zip中文件的枚举对象
while (zList.hasMoreElements()) { // 处理每个
ZipEntry ze = (ZipEntry) zList.nextElement(); // zipentry
if (ze.isDirectory()) {
continue;
}
// zipentry的输入流
InputStream isze = zip.getInputStream(ze);
InputStream is = new BufferedInputStream(isze);
// 对应zipentry的文件输出流
fout = new FileOutputStream(getRealFileName(unzippath + "/"
+ zipRealName, ze.getName()));
int readLen = 0;
// 写文件
while ((readLen = is.read(buf, 0, 1024)) != -1) {
fout.write(buf, 0, readLen);
}
// 关闭输出流
fout.close();
is.close();
isze.close();
if (ze.getName().endsWith(".zip")) { // 判断是否是xmlzip
// 如果是xmlzip包则解开xmlzip包
xmlpath = xmlunzip(unzippath + "/" + zipRealName + "/"
+ ze.getName(), unzippath + "/" + zipRealName);
}
}
zip.close();
return xmlpath;
} catch (Exception e) {
throw new AppException("文件类型不对,请确认是否为加密zip文件!");
} finally {
if (localfile != null) {
try {
FileUtility.forceDelete(localfile);
} catch(IOException ie) {
throw new AppException("删除文件出错", ie);
}
}
}
}
- 使用truezip解压缩zip文件
- 使用c#解压缩zip文件
- 使用ZLib 压缩/解压缩 zip文件
- 使用Objective-C解压缩ZIP文件教程
- 心得 ~ 使用 zlib库 解压缩 zip文件
- 使用Objective-C解压缩ZIP文件教程
- PHP解压缩zip文件,使用类ZipArchiv
- 使用Objective-C解压缩ZIP文件教程
- qt5.4.0使用quazip解压缩zip文件
- java 解压缩zip文件
- linux 解压缩zip文件
- java 解压缩zip文件
- PHP解压缩zip文件
- zip文件压缩解压缩
- Linux 解压缩Zip文件
- java解压缩zip文件
- java解压缩zip文件
- zip文件压缩解压缩
- 最为常用的正则表达式收集整理大全
- Symbian development on Linux and OS X
- linux下安装oracle 10g
- Net和MFC哪个更有前途,大家来讨论一下 (.NET技术 非技术区)
- 调用Qvod 方法详解
- 使用truezip解压缩zip文件
- 关于fckeditor(网页文本编辑器)
- vc无法设置断点的解决办法
- 遭遇Windows Update.exe/Trojan.Win32.Autoit.fc,情se发布器.exe/AdWare.Win32.Undef.eko
- 40个实用的轻量级JavaScript库
- 优化数据库
- [在线工具]链接生成工具,文本生成链接
- 如何不让UITableView滚动
- ORA-1461错误处理过程!