java 中压缩与解压
来源:互联网 发布:烟花算法 matlab 编辑:程序博客网 时间:2024/04/28 08:15
package com.common.util;
import java.io.*;
import java.util.ArrayList;
import java.util.zip.*;
public class UnZip {
public static int iCompressLevel; //压缩比 取值范围为0~9
public static boolean bOverWrite; //是否覆盖同名文件 取值范围为True和False
private static ArrayList allFiles = new ArrayList();
public static String sErrorMessage;
public static ArrayList unZip(String zipPathFile, String DestPath) {
ArrayList allFileName = new ArrayList();
try {
//先指定压缩档的位置和档名,建立FileInputStream对象
FileInputStream in = new FileInputStream(zipPathFile);
//将fins传入ZipInputStream中
ZipInputStream zin = new ZipInputStream(in);
ZipEntry ent = null;
byte ch[] = new byte[256];
while ((ent = zin.getNextEntry()) != null) {
File zfile = new File(DestPath + ent.getName());
File fpath = new File(zfile.getParentFile().getPath());
if (ent.isDirectory()) {
if (!zfile.exists())
zfile.mkdirs();
zin.closeEntry();
} else {
if (!fpath.exists())
fpath.mkdirs();
FileOutputStream fouts = new FileOutputStream(zfile);
int i;
allFileName.add(zfile.getAbsolutePath());
while ((i = zin.read(ch)) != -1)
fouts.write(ch, 0, i);
zin.closeEntry();
fouts.close();
}
//System.out.println("解压文件: " + ent.getName() + zipPathFile);
}
in.close();
zin.close();
sErrorMessage = "OK";
} catch (Exception e) {
System.err.println("Extract error:" + e.getMessage());
sErrorMessage = e.getMessage();
}
allFiles.clear();
System.out.println("完成");
return allFileName;
}
public static void main(String[] args) {
UnZip.unZip("c://order_20.rar", "c://un//");
}
}
- java 中压缩与解压
- java中对文件压缩与解压
- java中Gzip压缩与解压技术
- java 压缩与解压
- java 压缩与解压
- java压缩与解压文件
- Java文件解压与压缩
- java实现解压与压缩
- java压缩与解压压缩文件
- java文件压缩与解压
- java zip 压缩与解压
- Java中压缩与解压--中文文件名乱码解决办法
- Java中压缩与解压--中文文件名乱码解决办法
- Java中ZIP压缩与解压--中文文件名乱码解决办法
- java中zip与gzip实现文件压缩,解压
- liinux中压缩与解压命令
- Java压缩与解压rar文件
- java zip文件的压缩与解压
- 哈哈,扔一个纸团
- Javascript 代码片段 -- 禁止右键、选择、粘贴、shift、ctrl、alt.....
- Pe研究之:从内存中加载Pe文件(代码重定位,进程隐藏,代码注入)
- 给肌肤装屏保 对付电脑辐射
- 处理事件:C++,Java到JavaScript
- java 中压缩与解压
- IT程序员35岁之后的三条活路
- JS处理文件操作
- 使用异步 I/O 大大提高应用程序的性能
- Photoshop文字之——制作木板雕刻字
- ASP.NET2.0---C# 中需要注意的问题
- Data Structures and Algorithms with Object-Oriented Design Patterns (3)
- 匿名用户无权访问Portlet
- JSEclipse插件安装