private static Collection<String> readElementsFromArchive(File archive, String archiveDir) throws IOException { Collection<String> elements = new ArrayList<>(); try (ZipFile zipFile = new NestedZipFile(archive)) { String relPath = archiveDir.startsWith("/") ? archiveDir.substring(1) : archiveDir; Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (name.startsWith(relPath)) { elements.add(name.substring(relPath.length())); } } LOG.trace("{} element(s) read from {}.", elements.size(), archive); return elements; } }
/** * Gets the zip file. * * @return the zip file * * @throws IOException * Signals that an I/O exception has occurred. */ public ZipFile getZipFile() throws IOException { try { return new NestedZipFile(this.getFileArchiv()); } catch (IOException ioe) { throw new IOException("can't get zip file \"" + this.getFileArchiv() + '"', ioe); } }