Class ZipEntryHelper


  • public final class ZipEntryHelper
    extends Object
    Utility class to retrieve Path representing folders or files under a ZIP archive.
    • Method Detail

      • zipFileRoot

        public static Path zipFileRoot​(Path zipArchivePath)
                                throws IOException
        Return the Path of the root of the given ZIP archive.
        Parameters:
        zipArchivePath - The zip path
        Returns:
        the PAth of the root
        Throws:
        IOException - if an I/O error is thrown when accessing a file.
      • zipFileTree

        public static Stream<PathzipFileTree​(Path zipArchivePath,
                                               Optional<String> startingPath,
                                               BiPredicate<Path,​BasicFileAttributes> filter)
                                        throws IOException
        Returns a Stream that is lazily populated with Path by searching for files in a file tree rooted at a given starting path within the ZIP, or the ZIP root.
        Parameters:
        zipArchivePath - The zip path
        startingPath - The (optional) starting path within the ZIP
        filter - The filter
        Returns:
        the Stream of Path
        Throws:
        IOException - if an I/O error is thrown when accessing a file.
      • zipEntryFolderExists

        public static boolean zipEntryFolderExists​(Path zipPath,
                                                   String zipEntryFolderPath)
                                            throws IOException
        Checks if the given folder entry exists in the ZIP archive.
        Parameters:
        zipPath - The zip path
        zipEntryFolderPath - The path of the folder within the ZIP
        Returns:
        true if the entry exists
        Throws:
        IOException - if an I/O error is thrown when accessing a file.
      • zipEntryFileExists

        public static boolean zipEntryFileExists​(Path zipPath,
                                                 String zipEntryFilePath)
                                          throws IOException
        Checks if the given file entry exists in the ZIP archive.
        Parameters:
        zipPath - The zip path
        zipEntryFilePath - The path of the file within the ZIP
        Returns:
        true if the entry exists
        Throws:
        IOException - if an I/O error is thrown when accessing a file.