没有合适的资源?快使用搜索试试~ 我知道了~
java 压缩/解压 .zip/.rar/.tar 文件
4星 · 超过85%的资源 需积分: 47 58 下载量 15 浏览量
2009-03-19
15:05:13
上传
评论 3
收藏 11KB DOC 举报
温馨提示
试读
7页
java 压缩/解压 .zip/.rar/.tar 文件,大家一起讨论,学习 已实现zip压缩/解压,rar解压
资源推荐
资源详情
资源评论
package com.by.tm.decompression;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.tools.tar.TarEntry;
import org.apache.tools.tar.TarOutputStream;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.apache.tools.zip.ZipOutputStream;
import de.innosystec.unrar.Archive;
/**
* @author Every E-mail/MSN:mwgjkf@hotmail.com
* QQ:30130942
* @version ʱ���� �䣺 Feb 26, 2009 6:01:11 PM
* ˵ :ѹ ѹ ļ�� �� ��� � �������
*
*/
public class Decompression {
private static final int BUFFEREDSIZE = 1024;
public Decompression() {
// TODO Auto-generated constructor stub
}
/**
* ѹzip ʽ ѹ ļ ǰ ļ�� �� �� ��� ����� � ���
* @param zipFileName
* @throws Exception
*/
@SuppressWarnings("unchecked")
public synchronized void unzipFile(String zipFileName) throws Exception {
try {
File f = new File(zipFileName);
ZipFile zipFile = new ZipFile(zipFileName);
if((!f.exists()) && (f.length() <= 0)) {
throw new Exception("Ҫ ѹ ļ !");�� ��� �������
}
String strPath, gbkPath, strtemp;
File tempFile = new File(f.getParent());
strPath = tempFile.getAbsolutePath();
java.util.Enumeration e = zipFile.getEntries();
while(e.hasMoreElements()){
org.apache.tools.zip.ZipEntry zipEnt = (ZipEntry)
e.nextElement();
gbkPath=zipEnt.getName();
if(zipEnt.isDirectory()){
strtemp = strPath + "/" + gbkPath;
File dir = new File(strtemp);
dir.mkdirs();
continue;
} else {
// д ļ�� � �
InputStream is = zipFile.getInputStream(zipEnt);
BufferedInputStream bis = new
BufferedInputStream(is);
gbkPath=zipEnt.getName();
strtemp = strPath + "/" + gbkPath;
资源评论
- zoujunhua862012-08-31貌似可 以用
- he201010202012-09-25少包,com.by.tm.decompression这个包还真不知道哪里有。
- 普通网友2014-03-13运行有问题!
- anpire2011-12-24怎么用java写压缩与解压缩的程序都不鞥运行啊。有很多错误。
wang_zilu
- 粉丝: 5
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功