Распаковка файла Zip, немного сложнее чем упаковка.

Пример

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
String zipFile="C:\\MyFile.zip";
String outputFolder="C:\\outputzip";
 
byte[] buffer = new byte[1024];
try{

File folder = new File(outputFolder);
if(!folder.exists()){
 folder.mkdir();
}
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile));

ZipEntry ze = zis.getNextEntry();
 
while(ze!=null){
 
String fileName = ze.getName();
File newFile = new File(outputFolder + File.separator + fileName);
 
System.out.println("file unzip : "+ newFile.getAbsoluteFile());

new File(newFile.getParent()).mkdirs();
 
FileOutputStream fos = new FileOutputStream(newFile);            
 
int len;
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
 
fos.close();  
ze = zis.getNextEntry();
}
zis.closeEntry();
zis.close();
 
System.out.println("Done");
 
}catch(IOException ex){
 ex.printStackTrace();
}