@Immutable public final class Paths extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Paths.Normalizer
A normalizer for path names.
|
static class |
Paths.Splitter
Splits a given path name into its parent path name and member name.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
contains(String a,
String b,
char separatorChar)
Returns true if and only if the path name represented by
a
contains the path name represented by b . |
static String |
cutTrailingSeparators(String path,
char separatorChar)
Cuts off any separator characters at the end of the given path name,
unless the path name contains of only separator characters, in which
case a single separator character is retained to denote the root
directory.
|
static boolean |
isAbsolute(String path,
char separatorChar)
Returns
true iff the given path name is absolute. |
static boolean |
isRoot(String path)
Returns
true iff the given path name refers to the root
directory, i.e. |
static String |
normalize(String path,
char separatorChar)
Equivalent to
new . |
static int |
prefixLength(String path,
char separatorChar,
boolean inclUNC)
Returns the length of the file system prefix in
path . |
static Paths.Splitter |
split(String path,
char separatorChar,
boolean keepTrailingSeparator)
Equivalent to
new . |
public static boolean contains(String a, String b, char separatorChar)
a
contains the path name represented by b
.
If and only if this JVM is running on Windows, the comparison is case
insensitive with respect to the
default locale
.public static String cutTrailingSeparators(String path, char separatorChar)
path
- The path name to chop.separatorChar
- The file name separator character.path
if it's a path name without trailing separators
or contains the separator character only.
Otherwise, the substring until the first of at least one
separating characters is returned.public static boolean isAbsolute(String path, char separatorChar)
true
iff the given path name is absolute.
Windows drives and UNC's are recognized if and only if this JVM is
running on Windows.path
- the path name to test.separatorChar
- the file name separator character.public static boolean isRoot(String path)
true
iff the given path name refers to the root
directory, i.e. if it's empty.public static String normalize(String path, char separatorChar)
new Normalizer(separatorChar)
.normalize(path)
.public static int prefixLength(String path, char separatorChar, boolean inclUNC)
path
.
File system prefixes are:
inclUNC
is true
, then the next two segments
following the two leading separators are accounted for in the prefix
length as the UNC host and share name.
path
- The file system path.separatorChar
- The file name separator character.inclUNC
- whether or not an authority or a UNC host and
share name should get accounted for in the prefix length.public static Paths.Splitter split(String path, char separatorChar, boolean keepTrailingSeparator)
new Splitter(separatorChar, keepTrailingSeparator)
.split(path)
.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.