String dest = destination;
if (!destination.endsWith(File.separator)) {
dest = destination + File.separator;
}
ZipFile zf = null;
try {
zf = new ZipFile(zipFile);
@SuppressWarnings("unchecked")
Enumeration<ZipEntry> enu = zf.getEntries();
while (enu.hasMoreElements()) {
ZipEntry entry = (ZipEntry) enu.nextElement();
String name = entry.getName();
String path = dest + name;
File file = new File(path);
if (entry.isDirectory()) {
file.mkdirs();
} else {
InputStream is = zf.getInputStream(entry);
byte[] buf1 = new byte[1024];
int len;
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
OutputStream out = new FileOutputStream(file);
while ((len = is.read(buf1)) > 0) {
out.write(buf1, 0, len);
}
out.flush();
out.close();
is.close();
fileNames.add(file.getAbsolutePath());
}
}
zf.close();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (null != zf) {
try {
zf.close();
} catch (IOException e) {
}
}
}
return fileNames;