I have a zip file that can contain any number of zip files inside it (recursively). I need to sort through all of them.
Right now I have a function that takes zipInputStream and zipFile as parameters. Problem in; if I get a zip inside another zip, I call this function again again. Therefore, I do not know how to create a zipFile object for zip files inside another zip file. Can anyone suggest a way to do this? You have come across this before.
The fragment will look as follows.
private void checkZIP(ZipInputStream zInpStream, ZipFile zf) {
try {
ZipEntry zipEntry = zInpStream.getNextEntry();
while (zipEntry != null) {
String entryName = zipEntry.getName();
if(entryName.endsWith(".zip"))
checkZIP(new ZipInputStream(zf.getInputStream(zipEntry)),<NEW ZIPFILE OBJECT FOR THIS ENTRY>);
zInpStream.closeEntry();
zipEntry = zInpStream.getNextEntry();
}
zInpStream.close();
} catch(Exception ioe) {
}
}
EDIT: zip , . XML , Document. , zipInputStream parse() DocumentBuilder, , . (ZipFile object).getInputStream(currentEntryForXML) DocumentBuilder parse().