java.util.zip.ZipInputStream zis = new java.util.zip.ZipInputStream(new BufferedInputStream(is));
java.util.zip.ZipEntry entry;
new File(outdir+ File.separator+"changelog").delete();
new File(outdir+ File.separator+"media").delete();
try {
while ((entry = zis.getNextEntry()) != null) {
File of = new File(outdir + File.separator + entry.getName());
if (entry.isDirectory()) {
of.mkdirs();
continue;
} else {
File xx = new File(of.getParent());
if (!xx.exists()) {
Stack<String> todo = new Stack<String>();
do {
todo.push(xx.getAbsolutePath());
xx = new File(xx.getParent());
} while (!xx.exists());
while (todo.size() > 0) {
xx = new File(todo.pop());
if (!xx.exists()) {
xx.mkdirs();
}
}
}
}
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(of), buffer.length);
cpio(new BufferedInputStream(zis), bos, "unzip:" + entry.getName());
bos.flush();
bos.close();
}
} catch (IllegalArgumentException e) {
// problem with chars in entry name likely
}catch(Exception e){
System.out.println(e+"Srikanth");
}
zis.close();
}
entry.isDirectory()总是返回 false,所以它创建的是文件而不是目录。问题是什么?