@Test public void testGetZipDirRoots() { Set<String> dirs = fileUtility.getZipRootDirs(SRC_TEST_RESOURCES + "instance-template-7.0.55.zip"); LOGGER.info("Size {}", dirs.size()); assertEquals(dirs.size(), 7); }
public Set<String> getZipRootDirs(final String zipFilename) { final Set<String> zipRootDirs = new HashSet<>(); try { if (zipFilename.indexOf(TAR_GZIP_FILE_EXT) > 0) { return getGZipRootDirs(zipFilename); } final ZipFile zipFile = new ZipFile(zipFilename); final Enumeration zipEntryEnumeration = zipFile.entries(); while (zipEntryEnumeration.hasMoreElements()) { final String zipEntry = zipEntryEnumeration.nextElement().toString(); final int slashIdx = zipEntry.indexOf('/'); if (slashIdx > 0) { zipRootDirs.add(zipEntry.substring(0, slashIdx)); } } zipFile.close(); return zipRootDirs; } catch (final IOException e) { throw new FileUtilityException(MessageFormat.format("Failed to get {0} parent path!", zipFilename), e); } }
FileUtility { public Set<String> getZipRootDirs(final String zipFilename) { final Set<String> zipRootDirs = new HashSet<>(); try { if (zipFilename.indexOf(TAR_GZIP_FILE_EXT) > 0) { return getGZipRootDirs(zipFilename); } final ZipFile zipFile = new ZipFile(zipFilename); final Enumeration zipEntryEnumeration = zipFile.entries(); while (zipEntryEnumeration.hasMoreElements()) { final String zipEntry = zipEntryEnumeration.nextElement().toString(); final int slashIdx = zipEntry.indexOf('/'); if (slashIdx > 0) { zipRootDirs.add(zipEntry.substring(0, slashIdx)); } } zipFile.close(); return zipRootDirs; } catch (final IOException e) { throw new FileUtilityException(MessageFormat.format("Failed to get {0} parent path!", zipFilename), e); } } }
FileUtility { public Set<String> getZipRootDirs(final String zipFilename) { final Set<String> zipRootDirs = new HashSet<>(); try { if (zipFilename.indexOf(TAR_GZIP_FILE_EXT) > 0) { return getGZipRootDirs(zipFilename); } final ZipFile zipFile = new ZipFile(zipFilename); final Enumeration zipEntryEnumeration = zipFile.entries(); while (zipEntryEnumeration.hasMoreElements()) { final String zipEntry = zipEntryEnumeration.nextElement().toString(); final int slashIdx = zipEntry.indexOf('/'); if (slashIdx > 0) { zipRootDirs.add(zipEntry.substring(0, slashIdx)); } } zipFile.close(); return zipRootDirs; } catch (final IOException e) { throw new FileUtilityException(MessageFormat.format("Failed to get {0} parent path!", zipFilename), e); } }  }
FileUtility { public Set<String> getZipRootDirs(final String zipFilename) { final Set<String> zipRootDirs = new HashSet<>(); try { if (zipFilename.indexOf(TAR_GZIP_FILE_EXT) > 0) { return getGZipRootDirs(zipFilename); } final ZipFile zipFile = new ZipFile(zipFilename); final Enumeration zipEntryEnumeration = zipFile.entries(); while (zipEntryEnumeration.hasMoreElements()) { final String zipEntry = zipEntryEnumeration.nextElement().toString(); final int slashIdx = zipEntry.indexOf('/'); if (slashIdx > 0) { zipRootDirs.add(zipEntry.substring(0, slashIdx)); } } zipFile.close(); return zipRootDirs; } catch (final IOException e) { throw new FileUtilityException(MessageFormat.format("Failed to get {0} parent path!", zipFilename), e); } }  void unzip(final File zipFile, final File destination); Set<String> getZipRootDirs(final String zipFilename); void createJarArchive(File archiveFile, File[] filesToBeJared, String parent); static Set<String> getGZipRootDirs(String tarGzipFile); static String getCheckSum(final String fileAbsolutePath); }
FileUtility { public Set<String> getZipRootDirs(final String zipFilename) { final Set<String> zipRootDirs = new HashSet<>(); try { if (zipFilename.indexOf(TAR_GZIP_FILE_EXT) > 0) { return getGZipRootDirs(zipFilename); } final ZipFile zipFile = new ZipFile(zipFilename); final Enumeration zipEntryEnumeration = zipFile.entries(); while (zipEntryEnumeration.hasMoreElements()) { final String zipEntry = zipEntryEnumeration.nextElement().toString(); final int slashIdx = zipEntry.indexOf('/'); if (slashIdx > 0) { zipRootDirs.add(zipEntry.substring(0, slashIdx)); } } zipFile.close(); return zipRootDirs; } catch (final IOException e) { throw new FileUtilityException(MessageFormat.format("Failed to get {0} parent path!", zipFilename), e); } }  void unzip(final File zipFile, final File destination); Set<String> getZipRootDirs(final String zipFilename); void createJarArchive(File archiveFile, File[] filesToBeJared, String parent); static Set<String> getGZipRootDirs(String tarGzipFile); static String getCheckSum(final String fileAbsolutePath);  }