Class FilenameUtils
When dealing with file names, you can hit problems when moving from a Windows based development machine to a Unix based production machine. This class aims to help avoid those problems.
 NOTE: You may be able to avoid using this class entirely simply by
 using JDK File objects and the two argument constructor
 File(File,String).
 
Most methods in this class are designed to work the same on both Unix and Windows. Those that don't include 'System', 'Unix', or 'Windows' in their name.
Most methods recognize both separators (forward and backslashes), and both sets of prefixes. See the Javadoc of each method for details.
This class defines six components within a path (sometimes called a file name or a full file name). Given an absolute Windows path such as C:\dev\project\file.txt they are:
- the full file name, or just file name - C:\dev\project\file.txt
- the prefix - C:\
- the path - dev\project\
- the full path - C:\dev\project\
- the name - file.txt
- the base name - file
- the extension - txt
Given an absolute Unix path such as /dev/project/file.txt they are:
- the full file name, or just file name - /dev/project/file.txt
- the prefix - /
- the path - dev/project
- the full path - /dev/project
- the name - file.txt
- the base name - file
- the extension - txt
Given a relative Windows path such as dev\project\file.txt they are:
- the full file name, or just file name - dev\project\file.txt
- the prefix - null
- the path - dev\project\
- the full path - dev\project\
- the name - file.txt
- the base name - file
- the extension - txt
Given an absolute Unix path such as /dev/project/file.txt they are:
- the full path, full file name, or just file name - /dev/project/file.txt
- the prefix - /
- the path - dev/project
- the full path - /dev/project
- the name - file.txt
- the base name - file
- the extension - txt
This class works best if directory names end with a separator. If you omit the last separator, it is impossible to determine if the last component corresponds to a file or a directory. This class treats final components that do not end with a separator as files, not directories.
This class only supports Unix and Windows style names. Prefixes are matched as follows:
Windows: a\b\c.txt --> "" --> relative \a\b\c.txt --> "\" --> current drive absolute C:a\b\c.txt --> "C:" --> drive relative C:\a\b\c.txt --> "C:\" --> absolute \\server\a\b\c.txt --> "\\server\" --> UNC Unix: a/b/c.txt --> "" --> relative /a/b/c.txt --> "/" --> absolute ~/a/b/c.txt --> "~/" --> current user ~ --> "~/" --> current user (slash added) ~user/a/b/c.txt --> "~user/" --> named user ~user --> "~user/" --> named user (slash added)
Both prefix styles are matched, irrespective of the machine that you are currently running on.
- Since:
- 1.1
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final charThe extension separator character.static final StringThe extension separator String.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringConcatenates a fileName to a base path using normal command line style rules.static booleandirectoryContains(String canonicalParent, String canonicalChild) Determines whether theparentdirectory contains thechild(a file or directory).static booleanChecks whether two file names are exactly equal.static booleanChecks whether two file names are equal, optionally normalizing and providing control over the case-sensitivity.static booleanequalsNormalized(String fileName1, String fileName2) Checks whether two file names are equal after both have been normalized.static booleanequalsNormalizedOnSystem(String fileName1, String fileName2) Checks whether two file names are equal using the case rules of the system after both have been normalized.static booleanequalsOnSystem(String fileName1, String fileName2) Checks whether two file names are equal using the case rules of the system.static StringgetBaseName(String fileName) Gets the base name, minus the full path and extension, from a full file name.static StringgetExtension(String fileName) Gets the extension of a file name.static StringgetFullPath(String fileName) Gets the full path (prefix + path) from a full file name.static StringgetFullPathNoEndSeparator(String fileName) Gets the full path (prefix + path) from a full file name, excluding the final directory separator.static StringGets the name minus the path from a full file name.static StringGets the path from a full file name, which excludes the prefix and the name.static StringgetPathNoEndSeparator(String fileName) Gets the path (which excludes the prefix) from a full file name, and also excluding the final directory separator.static StringGets the prefix such asC:/or~/from a full file name,static intgetPrefixLength(String fileName) Returns the length of the file name prefix, such asC:/or~/.static intindexOfExtension(String fileName) Returns the index of the last extension separator character, which is a period.static intindexOfLastSeparator(String fileName) Returns the index of the last directory separator character.static booleanisExtension(String fileName, String extension) Checks whether the extension of the file name is that specified.static booleanisExtension(String fileName, String... extensions) Checks whether the extension of the file name is one of those specified.static booleanisExtension(String fileName, Collection<String> extensions) Checks whether the extension of the file name is one of those specified.static StringNormalizes a path, removing double and single period path steps.static StringNormalizes a path, removing double and single period path steps.static StringnormalizeNoEndSeparator(String fileName) Normalizes a path, removing double and single period path steps, and removing any final directory separator.static StringnormalizeNoEndSeparator(String fileName, boolean unixSeparator) Normalizes a path, removing double and single period path steps, and removing any final directory separator.static StringremoveExtension(String fileName) Removes the extension from a fileName.static StringseparatorsToSystem(String path) Converts all separators to the system separator.static StringseparatorsToUnix(String path) Converts all separators to the Unix separator of forward slash.static StringseparatorsToWindows(String path) Converts all separators to the Windows separator of backslash.static booleanwildcardMatch(String fileName, String wildcardMatcher) Checks a fileName to see if it matches the specified wildcard matcher, always testing case-sensitive.static booleanwildcardMatch(String fileName, String wildcardMatcher, IOCase ioCase) Checks a fileName to see if it matches the specified wildcard matcher allowing control over case-sensitivity.static booleanwildcardMatchOnSystem(String fileName, String wildcardMatcher) Checks a fileName to see if it matches the specified wildcard matcher using the case rules of the system.
- 
Field Details- 
EXTENSION_SEPARATORThe extension separator character.- Since:
- 1.4
- See Also:
 
- 
EXTENSION_SEPARATOR_STRThe extension separator String.- Since:
- 1.4
 
 
- 
- 
Constructor Details- 
FilenameUtilsDeprecated.TODO Make private in 3.0.Instances should NOT be constructed in standard programming.
 
- 
- 
Method Details- 
concatConcatenates a fileName to a base path using normal command line style rules.The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument. The first argument is the base path, the second is the path to concatenate. The returned path is always normalized via normalize(String), thus..is handled.If pathToAddis absolute (has an absolute prefix), then it will be normalized and returned. Otherwise, the paths will be joined, normalized and returned.The output will be the same on both Unix and Windows except for the separator character. /foo/ + bar --> /foo/bar /foo + bar --> /foo/bar /foo + /bar --> /bar /foo + C:/bar --> C:/bar /foo + C:bar --> C:bar [1] /foo/a/ + ../bar --> /foo/bar /foo/ + ../../bar --> null /foo/ + /bar --> /bar /foo/.. + /bar --> /bar /foo + bar/c.txt --> /foo/bar/c.txt /foo/c.txt + bar --> /foo/c.txt/bar [2] [1] Note that the Windows relative drive prefix is unreliable when used with this method. [2] Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use getFullPath(String)on the base path argument.- Parameters:
- basePath- the base path to attach to, always treated as a path
- fullFileNameToAdd- the file name (or path) to attach to the base
- Returns:
- the concatenated path, or null if invalid
- Throws:
- IllegalArgumentException- if the result path contains the null character (- U+0000)
 
- 
directoryContainsDetermines whether theparentdirectory contains thechild(a file or directory). This does not read from the file system, and there is no guarantee or expectation that these paths actually exist.The files names are expected to be normalized. Edge cases:- A directorymust not be null: if null, throw IllegalArgumentException
- A directory does not contain itself: return false
- A null child file is not contained in any parent: return false
 - Parameters:
- canonicalParent- the path string to consider as the parent.
- canonicalChild- the path string to consider as the child.
- Returns:
- true if the candidate leaf is under the specified composite. False otherwise.
- Since:
- 2.2
- See Also:
 
- A 
- 
equalsChecks whether two file names are exactly equal.No processing is performed on the file names other than comparison. This is merely a null-safe case-sensitive string equality. - Parameters:
- fileName1- the first file name, may be null
- fileName2- the second file name, may be null
- Returns:
- true if the file names are equal, null equals null
- See Also:
 
- 
equalsChecks whether two file names are equal, optionally normalizing and providing control over the case-sensitivity.- Parameters:
- fileName1- the first file name, may be null
- fileName2- the second file name, may be null
- normalize- whether to normalize the file names
- ioCase- what case sensitivity rule to use, null means case-sensitive
- Returns:
- true if the file names are equal, null equals null
- Since:
- 1.3
 
- 
equalsNormalizedChecks whether two file names are equal after both have been normalized.Both file names are first passed to normalize(String). The check is then performed in a case-sensitive manner.- Parameters:
- fileName1- the first file name, may be null
- fileName2- the second file name, may be null
- Returns:
- true if the file names are equal, null equals null
- See Also:
 
- 
equalsNormalizedOnSystemChecks whether two file names are equal using the case rules of the system after both have been normalized.Both file names are first passed to normalize(String). The check is then performed case-sensitively on Unix and case-insensitively on Windows.- Parameters:
- fileName1- the first file name, may be null
- fileName2- the second file name, may be null
- Returns:
- true if the file names are equal, null equals null
- See Also:
 
- 
equalsOnSystemChecks whether two file names are equal using the case rules of the system.No processing is performed on the file names other than comparison. The check is case-sensitive on Unix and case-insensitive on Windows. - Parameters:
- fileName1- the first file name, may be null
- fileName2- the second file name, may be null
- Returns:
- true if the file names are equal, null equals null
- See Also:
 
- 
getBaseNameGets the base name, minus the full path and extension, from a full file name.This method will handle a path in either Unix or Windows format. The text after the last forward or backslash and before the last period is returned. a/b/c.txt --> c a\b\c.txt --> c a/b/c.foo.txt --> c.foo a.txt --> a a/b/c --> c a/b/c/ --> "" The output will be the same irrespective of the machine that the code is running on. - Parameters:
- fileName- the file name, null returns null
- Returns:
- the name of the file without the path, or an empty string if none exists
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
 
- 
getExtensionGets the extension of a file name.This method returns the textual part of the file name after the last period. There must be no directory separator after the period. foo.txt --> "txt" a/b/c.jpg --> "jpg" a/b.txt/c --> "" a/b/c --> "" The output will be the same irrespective of the machine that the code is running on, with the exception of a possible IllegalArgumentExceptionon Windows (see below).Note: This method used to have a hidden problem for names like "foo.exe:bar.txt". In this case, the name wouldn't be the name of a file, but the identifier of an alternate data stream (bar.txt) on the file foo.exe. The method used to return ".txt" here, which would be misleading. Commons IO 2.7 and later throw an IllegalArgumentExceptionfor names like this.- Parameters:
- fileName- the file name to retrieve the extension of.
- Returns:
- the extension of the file or an empty string if none exists or nullif the file name isnull.
- Throws:
- IllegalArgumentException- Windows only: the file name parameter is, in fact, the identifier of an Alternate Data Stream, for example "foo.exe:bar.txt".
 
- 
getFullPathGets the full path (prefix + path) from a full file name.This method will handle a file in either Unix or Windows format. The method is entirely text based, and returns the text before and including the last forward or backslash. C:\a\b\c.txt --> C:\a\b\ ~/a/b/c.txt --> ~/a/b/ a.txt --> "" a/b/c --> a/b/ a/b/c/ --> a/b/c/ C: --> C: C:\ --> C:\ ~ --> ~/ ~/ --> ~/ ~user --> ~user/ ~user/ --> ~user/ The output will be the same irrespective of the machine that the code is running on. - Parameters:
- fileName- the file name, null returns null
- Returns:
- the path of the file, an empty string if none exists, null if invalid
- Throws:
- IllegalArgumentException- if the result path contains the null character (- U+0000)
 
- 
getFullPathNoEndSeparatorGets the full path (prefix + path) from a full file name, excluding the final directory separator.This method will handle a file in either Unix or Windows format. The method is entirely text based, and returns the text before the last forward or backslash. C:\a\b\c.txt --> C:\a\b ~/a/b/c.txt --> ~/a/b a.txt --> "" a/b/c --> a/b a/b/c/ --> a/b/c C: --> C: C:\ --> C:\ ~ --> ~ ~/ --> ~ ~user --> ~user ~user/ --> ~user The output will be the same irrespective of the machine that the code is running on. - Parameters:
- fileName- the file name, null returns null
- Returns:
- the path of the file, an empty string if none exists, null if invalid
- Throws:
- IllegalArgumentException- if the result path contains the null character (- U+0000)
 
- 
getNameGets the name minus the path from a full file name.This method will handle a file in either Unix or Windows format. The text after the last forward or backslash is returned. a/b/c.txt --> c.txt a\b\c.txt --> c.txt a.txt --> a.txt a/b/c --> c a/b/c/ --> "" The output will be the same irrespective of the machine that the code is running on. - Parameters:
- fileName- the file name, null returns null
- Returns:
- the name of the file without the path, or an empty string if none exists
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
 
- 
getPathGets the path from a full file name, which excludes the prefix and the name.This method will handle a file in either Unix or Windows format. The method is entirely text based, and returns the text before and including the last forward or backslash. C:\a\b\c.txt --> a\b\ ~/a/b/c.txt --> a/b/ a.txt --> "" a/b/c --> a/b/ a/b/c/ --> a/b/c/ The output will be the same irrespective of the machine that the code is running on. This method drops the prefix from the result. See getFullPath(String)for the method that retains the prefix.- Parameters:
- fileName- the file name, null returns null
- Returns:
- the path of the file, an empty string if none exists, null if invalid
- Throws:
- IllegalArgumentException- if the result path contains the null character (- U+0000)
 
- 
getPathNoEndSeparatorGets the path (which excludes the prefix) from a full file name, and also excluding the final directory separator.This method will handle a file in either Unix or Windows format. The method is entirely text based, and returns the text before the last forward or backslash. C:\a\b\c.txt --> a\b ~/a/b/c.txt --> a/b a.txt --> "" a/b/c --> a/b a/b/c/ --> a/b/c The output will be the same irrespective of the machine that the code is running on. This method drops the prefix from the result. See getFullPathNoEndSeparator(String)for the method that retains the prefix.- Parameters:
- fileName- the file name, null returns null
- Returns:
- the path of the file, an empty string if none exists, null if invalid
- Throws:
- IllegalArgumentException- if the result path contains the null character (- U+0000)
 
- 
getPrefixGets the prefix such asC:/or~/from a full file name,This method will handle a file in either Unix or Windows format. The prefix includes the first slash in the full file name where applicable. Windows: a\b\c.txt --> "" --> relative \a\b\c.txt --> "\" --> current drive absolute C:a\b\c.txt --> "C:" --> drive relative C:\a\b\c.txt --> "C:\" --> absolute \\server\a\b\c.txt --> "\\server\" --> UNC Unix: a/b/c.txt --> "" --> relative /a/b/c.txt --> "/" --> absolute ~/a/b/c.txt --> "~/" --> current user ~ --> "~/" --> current user (slash added) ~user/a/b/c.txt --> "~user/" --> named user ~user --> "~user/" --> named user (slash added) The output will be the same irrespective of the machine that the code is running on. ie. both Unix and Windows prefixes are matched regardless. - Parameters:
- fileName- the file name, null returns null
- Returns:
- the prefix of the file, null if invalid
- Throws:
- IllegalArgumentException- if the result contains the null character (- U+0000)
 
- 
getPrefixLengthReturns the length of the file name prefix, such asC:/or~/.This method will handle a file in either Unix or Windows format. The prefix length includes the first slash in the full file name if applicable. Thus, it is possible that the length returned is greater than the length of the input string. Windows: a\b\c.txt --> 0 --> relative \a\b\c.txt --> 1 --> current drive absolute C:a\b\c.txt --> 2 --> drive relative C:\a\b\c.txt --> 3 --> absolute \\server\a\b\c.txt --> 9 --> UNC \\\a\b\c.txt --> -1 --> error Unix: a/b/c.txt --> 0 --> relative /a/b/c.txt --> 1 --> absolute ~/a/b/c.txt --> 2 --> current user ~ --> 2 --> current user (slash added) ~user/a/b/c.txt --> 6 --> named user ~user --> 6 --> named user (slash added) //server/a/b/c.txt --> 9 ///a/b/c.txt --> -1 --> error C: --> 0 --> valid file name as only null character and / are reserved characters The output will be the same irrespective of the machine that the code is running on. ie. both Unix and Windows prefixes are matched regardless. Note that a leading // (or \\) is used to indicate a UNC name on Windows. These must be followed by a server name, so double-slashes are not collapsed to a single slash at the start of the file name. - Parameters:
- fileName- the file name to find the prefix in, null returns -1
- Returns:
- the length of the prefix, -1 if invalid or null
 
- 
indexOfExtensionReturns the index of the last extension separator character, which is a period.This method also checks that there is no directory separator after the last period. To do this it uses indexOfLastSeparator(String)which will handle a file in either Unix or Windows format.The output will be the same irrespective of the machine that the code is running on, with the exception of a possible Note: This method used to have a hidden problem for names like "foo.exe:bar.txt". In this case, the name wouldn't be the name of a file, but the identifier of an alternate data stream (bar.txt) on the file foo.exe. The method used to return ".txt" here, which would be misleading. Commons IO 2.7, and later versions, are throwing anIllegalArgumentExceptionon Windows (see below).IllegalArgumentExceptionfor names like this.- Parameters:
- fileName- the file name to find the last extension separator in, null returns -1
- Returns:
- the index of the last extension separator character, or -1 if there is no such character
- Throws:
- IllegalArgumentException- Windows only: the file name parameter is, in fact, the identifier of an Alternate Data Stream, for example "foo.exe:bar.txt".
 
- 
indexOfLastSeparatorReturns the index of the last directory separator character.This method will handle a file in either Unix or Windows format. The position of the last forward or backslash is returned. The output will be the same irrespective of the machine that the code is running on. - Parameters:
- fileName- the file name to find the last path separator in, null returns -1
- Returns:
- the index of the last separator character, or -1 if there is no such character
 
- 
isExtensionChecks whether the extension of the file name is one of those specified.This method obtains the extension as the textual part of the file name after the last period. There must be no directory separator after the period. The extension check is case-sensitive on all platforms. - Parameters:
- fileName- the file name, null returns false
- extensions- the extensions to check for, null checks for no extension
- Returns:
- true if the file name is one of the extensions
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
 
- 
isExtensionChecks whether the extension of the file name is that specified.This method obtains the extension as the textual part of the file name after the last period. There must be no directory separator after the period. The extension check is case-sensitive on all platforms. - Parameters:
- fileName- the file name, null returns false
- extension- the extension to check for, null or empty checks for no extension
- Returns:
- true if the file name has the specified extension
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
 
- 
isExtensionChecks whether the extension of the file name is one of those specified.This method obtains the extension as the textual part of the file name after the last period. There must be no directory separator after the period. The extension check is case-sensitive on all platforms. - Parameters:
- fileName- the file name, null returns false
- extensions- the extensions to check for, null checks for no extension
- Returns:
- true if the file name is one of the extensions
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
 
- 
normalizeNormalizes a path, removing double and single period path steps.This method normalizes a path to a standard format. The input may contain separators in either Unix or Windows format. The output will contain separators in the format of the system. A trailing slash will be retained. A double slash will be merged to a single slash (but UNC names are handled). A single period path segment will be removed. A double period will cause that path segment and the one before to be removed. If the double period has no parent path segment, nullis returned.The output will be the same on both Unix and Windows except for the separator character. /foo// --> /foo/ /foo/./ --> /foo/ /foo/../bar --> /bar /foo/../bar/ --> /bar/ /foo/../bar/../baz --> /baz //foo//./bar --> //foo/bar /../ --> null ../foo --> null foo/bar/.. --> foo/ foo/../../bar --> null foo/../bar --> bar //server/foo/../bar --> //server/bar //server/../bar --> null C:\foo\..\bar --> C:\bar C:\..\bar --> null ~/foo/../bar/ --> ~/bar/ ~/../bar --> null (Note the file separator will be correct for Windows/Unix.)- Parameters:
- fileName- the file name to normalize, null returns null
- Returns:
- the normalized fileName, or null if invalid
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
 
- 
normalizeNormalizes a path, removing double and single period path steps.This method normalizes a path to a standard format. The input may contain separators in either Unix or Windows format. The output will contain separators in the format specified. A trailing slash will be retained. A double slash will be merged to a single slash (but UNC names are handled). A single period path segment will be removed. A double period will cause that path segment and the one before to be removed. If the double period has no parent path segment to work with, nullis returned.The output will be the same on both Unix and Windows except for the separator character. /foo// --> /foo/ /foo/./ --> /foo/ /foo/../bar --> /bar /foo/../bar/ --> /bar/ /foo/../bar/../baz --> /baz //foo//./bar --> /foo/bar /../ --> null ../foo --> null foo/bar/.. --> foo/ foo/../../bar --> null foo/../bar --> bar //server/foo/../bar --> //server/bar //server/../bar --> null C:\foo\..\bar --> C:\bar C:\..\bar --> null ~/foo/../bar/ --> ~/bar/ ~/../bar --> null The output will be the same on both Unix and Windows including the separator character.- Parameters:
- fileName- the file name to normalize, null returns null
- unixSeparator-- trueif a Unix separator should be used or- falseif a Windows separator should be used.
- Returns:
- the normalized fileName, or null if invalid
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
- Since:
- 2.0
 
- 
normalizeNoEndSeparatorNormalizes a path, removing double and single period path steps, and removing any final directory separator.This method normalizes a path to a standard format. The input may contain separators in either Unix or Windows format. The output will contain separators in the format of the system. A trailing slash will be removed. A double slash will be merged to a single slash (but UNC names are handled). A single period path segment will be removed. A double period will cause that path segment and the one before to be removed. If the double period has no parent path segment to work with, nullis returned.The output will be the same on both Unix and Windows except for the separator character. /foo// --> /foo /foo/./ --> /foo /foo/../bar --> /bar /foo/../bar/ --> /bar /foo/../bar/../baz --> /baz //foo//./bar --> /foo/bar /../ --> null ../foo --> null foo/bar/.. --> foo foo/../../bar --> null foo/../bar --> bar //server/foo/../bar --> //server/bar //server/../bar --> null C:\foo\..\bar --> C:\bar C:\..\bar --> null ~/foo/../bar/ --> ~/bar ~/../bar --> null (Note the file separator returned will be correct for Windows/Unix)- Parameters:
- fileName- the file name to normalize, null returns null
- Returns:
- the normalized fileName, or null if invalid
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
 
- 
normalizeNoEndSeparatorNormalizes a path, removing double and single period path steps, and removing any final directory separator.This method normalizes a path to a standard format. The input may contain separators in either Unix or Windows format. The output will contain separators in the format specified. A trailing slash will be removed. A double slash will be merged to a single slash (but UNC names are handled). A single period path segment will be removed. A double period will cause that path segment and the one before to be removed. If the double period has no parent path segment to work with, nullis returned.The output will be the same on both Unix and Windows including the separator character. /foo// --> /foo /foo/./ --> /foo /foo/../bar --> /bar /foo/../bar/ --> /bar /foo/../bar/../baz --> /baz //foo//./bar --> /foo/bar /../ --> null ../foo --> null foo/bar/.. --> foo foo/../../bar --> null foo/../bar --> bar //server/foo/../bar --> //server/bar //server/../bar --> null C:\foo\..\bar --> C:\bar C:\..\bar --> null ~/foo/../bar/ --> ~/bar ~/../bar --> null - Parameters:
- fileName- the file name to normalize, null returns null
- unixSeparator-- trueif a Unix separator should be used or- falseif a Windows separator should be used.
- Returns:
- the normalized fileName, or null if invalid
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
- Since:
- 2.0
 
- 
removeExtensionRemoves the extension from a fileName.This method returns the textual part of the file name before the last period. There must be no directory separator after the period. foo.txt --> foo .txt --> "" (empty string) a\b\c.jpg --> a\b\c /a/b/c.jpg --> /a/b/c a\b\c --> a\b\c a.b\c --> a.b\c The output will be the same irrespective of the machine that the code is running on. - Parameters:
- fileName- the file name, null returns null
- Returns:
- the file name minus the extension
- Throws:
- IllegalArgumentException- if the file name contains the null character (- U+0000)
 
- 
separatorsToSystemConverts all separators to the system separator.- Parameters:
- path- the path to be changed, null ignored.
- Returns:
- the updated path.
 
- 
separatorsToUnixConverts all separators to the Unix separator of forward slash.- Parameters:
- path- the path to be changed, null ignored.
- Returns:
- the new path.
 
- 
separatorsToWindowsConverts all separators to the Windows separator of backslash.- Parameters:
- path- the path to be changed, null ignored.
- Returns:
- the updated path.
 
- 
wildcardMatchChecks a fileName to see if it matches the specified wildcard matcher, always testing case-sensitive.The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. This is the same as often found on DOS/Unix command lines. The check is case-sensitive always. wildcardMatch("c.txt", "*.txt") --> true wildcardMatch("c.txt", "*.jpg") --> false wildcardMatch("a/b/c.txt", "a/b/*") --> true wildcardMatch("c.txt", "*.???") --> true wildcardMatch("c.txt", "*.????") --> falseThe sequence "*?" does not work properly at present in match strings.- Parameters:
- fileName- the file name to match on
- wildcardMatcher- the wildcard string to match against
- Returns:
- true if the file name matches the wildcard string
- See Also:
 
- 
wildcardMatchChecks 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. The sequence "*?" does not work properly at present in match strings. - Parameters:
- fileName- the file name 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 file name matches the wildcard string
- Since:
- 1.3
 
- 
wildcardMatchOnSystemChecks a fileName to see if it matches the specified wildcard matcher using the case rules of the system.The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. This is the same as often found on DOS/Unix command lines. The check is case-sensitive on Unix and case-insensitive on Windows. wildcardMatch("c.txt", "*.txt") --> true wildcardMatch("c.txt", "*.jpg") --> false wildcardMatch("a/b/c.txt", "a/b/*") --> true wildcardMatch("c.txt", "*.???") --> true wildcardMatch("c.txt", "*.????") --> falseThe sequence "*?" does not work properly at present in match strings.- Parameters:
- fileName- the file name to match on
- wildcardMatcher- the wildcard string to match against
- Returns:
- true if the file name matches the wildcard string
- See Also:
 
 
-