Class FileSystemPathUtil


  • public final class FileSystemPathUtil
    extends java.lang.Object
    Utility class for handling paths in a file system.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.BitSet SAFE_NAMECHARS
      The list of characters that are not encoded by the escapeName(String) and unescape(String) methods.
      static java.util.BitSet SAFE_PATHCHARS
      The list of characters that are not encoded by the escapePath(String) and unescape(String) methods.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkFormat​(java.lang.String path)
      Checks if path is a valid path.
      static boolean denotesRoot​(java.lang.String path)
      Tests whether the specified path represents the root path, i.e.
      static java.lang.String escapeName​(java.lang.String name)
      Encodes the specified name.
      static java.lang.String escapePath​(java.lang.String path)
      Encodes the specified path.
      static java.lang.String getName​(java.lang.String path)
      Returns the name of the specified path.
      static java.lang.String getParentDir​(java.lang.String path)
      Returns the parent directory of the specified path.
      static java.lang.String unescape​(java.lang.String pathOrName)
      Decodes the specified path/name.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SAFE_NAMECHARS

        public static final java.util.BitSet SAFE_NAMECHARS
        The list of characters that are not encoded by the escapeName(String) and unescape(String) methods. They contains the characters which can safely be used in file names:
      • SAFE_PATHCHARS

        public static final java.util.BitSet SAFE_PATHCHARS
        The list of characters that are not encoded by the escapePath(String) and unescape(String) methods. They contains the characters which can safely be used in file paths:
    • Method Detail

      • escapePath

        public static java.lang.String escapePath​(java.lang.String path)
        Encodes the specified path. Same as escapeName(String) except that the separator character / is regarded as a legal path character that needs no escaping.
        Parameters:
        path - the path to encode.
        Returns:
        the escaped path
      • escapeName

        public static java.lang.String escapeName​(java.lang.String name)
        Encodes the specified name. Same as escapePath(String) except that the separator character / is regarded as an illegal character that needs escaping.
        Parameters:
        name - the name to encode.
        Returns:
        the escaped name
      • unescape

        public static java.lang.String unescape​(java.lang.String pathOrName)
        Decodes the specified path/name.
        Parameters:
        pathOrName - the escaped path/name
        Returns:
        the unescaped path/name
      • denotesRoot

        public static boolean denotesRoot​(java.lang.String path)
        Tests whether the specified path represents the root path, i.e. "/".
        Parameters:
        path - path to test
        Returns:
        true if the specified path represents the root path; false otherwise.
      • checkFormat

        public static void checkFormat​(java.lang.String path)
                                throws FileSystemException
        Checks if path is a valid path.
        Parameters:
        path - the path to be checked
        Throws:
        FileSystemException - If path is not a valid path
      • getParentDir

        public static java.lang.String getParentDir​(java.lang.String path)
        Returns the parent directory of the specified path.
        Parameters:
        path - a file system path denoting a directory or a file.
        Returns:
        the parent directory.
      • getName

        public static java.lang.String getName​(java.lang.String path)
        Returns the name of the specified path.
        Parameters:
        path - a file system path denoting a directory or a file.
        Returns:
        the name.