UnZip file in java not so easy like pack it.

Example


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();
}