【发布时间】:2015-06-01 11:38:35
【问题描述】:
我想在内存中解压缩 *.docx 文件而不将输出写入磁盘。我找到了以下实现,但它只允许读取压缩文件而不能查看目录结构。知道目录树中每个文件的位置对我来说很重要。谁能给我一个方向?
private static void UnzipFileInMemory() {
try {
ZipFile zf = new ZipFile("d:\\a.docx");
int i = 0;
for (Enumeration e = zf.entries(); e.hasMoreElements();) {
InputStream in = null;
try {
ZipEntry entry = (ZipEntry) e.nextElement();
System.out.println(entry);
in = zf.getInputStream(entry);
} catch (IOException ex) {
//Logger.getLogger(Tester.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
in.close();
} catch (IOException ex) {
//Logger.getLogger(Tester.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
} catch (IOException ex) {
//Logger.getLogger(Tester.class.getName()).log(Level.SEVERE, null, ex);
}
}
【问题讨论】:
标签: java zip extract unzip in-memory