FileInputStream zf = new FileInputStream(zipFileName. toString());
ZipInputStream zipFile = new ZipInputStream(new BufferedInputStream(zf));
parseZipFile(zipFile, granularity);
...
private void parseZipFile(ZipInputStream zIS, PmGranularity granularity){
ZipEntry ze;
while((ze = zIS.getNextEntry()) != null){
String fname = ze.getName();
if (fname.endsWith(".zip")) {
parseZipFile(new ZipInputStream(new ZipClose(zIS)), granularity);
continue;
}
//DO SOMETHING LIKE PARSING TEXT FILES
zIS.closeEntry();
}
zIS.close();
}
private final class ZipClose extends java.io.FilterInputStream {
public ZipClose(ZipInputStream is) {
super(is);
}
@Override
public void close() throws IOException {
((ZipInputStream) in).closeEntry();
}
}
Sem comentários:
Enviar um comentário