Class FilenameUtils


  • public class FilenameUtils
    extends java.lang.Object
    This class is extracted from Apache commons-io project
    • Constructor Summary

      Constructors 
      Constructor Description
      FilenameUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static char flipSeparator​(char ch)
      Flips the Windows name separator to Linux and vice-versa.
      (package private) static java.lang.String[] splitOnTokens​(java.lang.String text)
      Splits a string into a number of tokens.
      static boolean wildcardMatch​(java.lang.String fileName, java.lang.String wildcardMatcher, IOCase ioCase)
      Checks a fileName to see if it matches the specified wildcard matcher allowing control over case-sensitivity.
      • Methods inherited from class java.lang.Object

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

      • EMPTY_STRING_ARRAY

        private static final java.lang.String[] EMPTY_STRING_ARRAY
      • UNIX_NAME_SEPARATOR

        private static final char UNIX_NAME_SEPARATOR
        The Unix separator character.
        See Also:
        Constant Field Values
      • WINDOWS_NAME_SEPARATOR

        private static final char WINDOWS_NAME_SEPARATOR
        The Windows separator character.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FilenameUtils

        public FilenameUtils()
    • Method Detail

      • wildcardMatch

        public static boolean wildcardMatch​(java.lang.String fileName,
                                            java.lang.String wildcardMatcher,
                                            IOCase ioCase)
        Checks a fileName to see if it matches the specified wildcard matcher allowing control over case-sensitivity.

        The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. N.B. the sequence "*?" does not work properly at present in match strings.

        Parameters:
        fileName - the fileName to match on
        wildcardMatcher - the wildcard string to match against
        ioCase - what case sensitivity rule to use, null means case-sensitive
        Returns:
        true if the fileName matches the wildcard string
        Since:
        1.3
      • splitOnTokens

        static java.lang.String[] splitOnTokens​(java.lang.String text)
        Splits a string into a number of tokens. The text is split by '?' and '*'. Where multiple '*' occur consecutively they are collapsed into a single '*'.
        Parameters:
        text - the text to split
        Returns:
        the array of tokens, never null
      • flipSeparator

        static char flipSeparator​(char ch)
        Flips the Windows name separator to Linux and vice-versa.
        Parameters:
        ch - The Windows or Linux name separator.
        Returns:
        The Windows or Linux name separator.