String path="d:\\dowload\\test.zip";
//解压到哪个文件下
String unzip="d:\\dowload\\ ";
File dirFile=new File(path);
ZipFile zipfile=null;
try{
if(dirFile.exists()){
zipfile=new ZipFile(path,"GBK");
Enumeration e=zipfile.getEntries();
while(e.hasMoreElements()){
ZipEntry zipEntry=(ZipEnrty) e.nextElement();
if(zipEntry.isDirectory()){
String name=zipEntry.getName();
name=name.subtring(0,name.length()-1);
File f=new File(unzip+name);
f.mkdirs();
}else{
File f=new File(unzip+zipEntry.getName());
f.getParentFile().mkdirs();
f.createNewFile();
InputStream is=zipFile.getInputStream(zipEntry);
FileOutputStream fos=new FileOutputStream(f);
int leng=0;
byte[] b=new byte[1024];
while((leng=is.read(b,0,1024)) !=-1){
fos.write(b,0,leng);
}
}
}
dirFile.deleteOnExit();//解压完之后删除zip文件
}
}catch(IOException e){
e.printStrackTreac();
}finally{
if(zipFile !=null){
zipFile.close();
}
}