阅读zip文件中的zip文件 [英] Read a zip file inside zip file
本文介绍了阅读zip文件中的zip文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的zip文件位于zip文件夹中,请建议我如何使用zip输入流阅读。
I have zip file which is inside a folder in zip file please suggest me how to read it using zip input stream.
EG:
abc.zip
|
documents/bcd.zip
如何读取zip文件中的zip文件?
How to read a zip file inside zip file?
推荐答案
如果你想以递归方式查看zip文件中的zip文件,
If you want to look through zip files within zip files recursively,
public void lookupSomethingInZip(InputStream fileInputStream) throws IOException {
ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
String entryName = "";
ZipEntry entry = zipInputStream.getNextEntry();
while (entry!=null) {
entryName = entry.getName();
if (entryName.endsWith("zip")) {
//recur if the entry is a zip file
lookupSomethingInZip(zipInputStream);
}
//do other operation with the entries..
entry=zipInputStream.getNextEntry();
}
}
使用从中派生的文件输入流调用方法file -
Call the method with the file input stream derived from the file -
File file = new File(name);
lookupSomethingInZip(new FileInputStream(file));
这篇关于阅读zip文件中的zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文