/**
* 解压课件包中的某个课件
* @param zipFilePath 课件包路径
* @param outDirPath 输出目录路径
* @return 解压出来文件的绝对路径,失败返回null
* @throws IOException
*/
public String decompressAllFileToDir(String zipFilePath, String outDirPath) throws IOException {
ZipFile zip = new ZipFile(zipFilePath, "GBK");
@SuppressWarnings("unchecked")
Enumeration
if (entries == null) {
return null;
}
java.io.File file = new java.io.File(outDirPath);
String path = file.getAbsolutePath();
file.mkdirs();
if (file.isFile()) {
return null;
}
while(entries.hasMoreElements())
{
ZipEntry entry = entries.nextElement();
String nameInZip = entry.getName().substring(entry.getName().lastIndexOf("/")+1);
InputStream is = zip.getInputStream(entry);
java.io.File tempFile = new java.io.File(nameInZip);
FileOutputStream fos = new FileOutputStream(new StringBuilder(path).append("/").append(tempFile.getName()).toString());
byte[] bytes = new byte[MAX_BUFFER];
int size = 0;
while ((size = is.read(bytes)) != -1) {
fos.write(bytes, 0, size);
}
}
return zipFilePath;
}