Class Path

    • Constructor Detail

      • Path

        public Path​(String fullPath)
        Constructs a new path from the given string path.

        The string path must represent a valid file system path on the local file system.

        The path is canonicalized and double slashes are removed except at the beginning. (to handle UNC paths). All forward slashes ('/') are treated as segment delimiters, and any segment and device delimiters for the local file system are also respected (such as colon (':') and backslash ('\') on some file systems).

        Parameters:
        fullPath - the string path
        See Also:
        isValidPath(String)
    • Method Detail

      • createFromAbsolutePath

        public static Path createFromAbsolutePath​(String path)
        Creates a path object from an absolute and canonical path.

        This method does not check the given path - it assumes the path has a valid format of the form "/a/b/c" without duplicate slashes or dots.

        Returns:
        the path
      • createFromSegments

        public static Path createFromSegments​(String[] segments)
      • addFileExtension

        public Path addFileExtension​(String extension)
      • addTrailingSeparator

        public Path addTrailingSeparator()
      • append

        public Path append​(Path tail)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getFileExtension

        public String getFileExtension()
      • hasTrailingSeparator

        public boolean hasTrailingSeparator()
      • isAbsolute

        public boolean isAbsolute()
      • isEmpty

        public boolean isEmpty()
      • isPrefixOf

        public boolean isPrefixOf​(Path anotherPath)
      • isRoot

        public boolean isRoot()
      • isValidPath

        public static boolean isValidPath​(String path)
      • lastSegment

        public String lastSegment()
      • makeAbsolute

        public Path makeAbsolute()
      • makeRelative

        public Path makeRelative()
      • matchingFirstSegments

        public int matchingFirstSegments​(Path anotherPath)
      • removeFileExtension

        public Path removeFileExtension()
      • removeFirstSegments

        public Path removeFirstSegments​(int count)
      • removeLastSegments

        public Path removeLastSegments​(int count)
      • removeTrailingSeparator

        public Path removeTrailingSeparator()
      • segment

        public String segment​(int index)
      • segmentCount

        public int segmentCount()
      • segments

        public String[] segments()
      • uptoSegment

        public Path uptoSegment​(int count)
      • getFileNameFromPath

        public static String getFileNameFromPath​(String iconPath)
        Gets the name of the icon file so that it can be displayed as alt text.