public class FilePath
extends java.lang.Object
Path class. The main difference is
that a FilePath supports the ".." relative path element (representing a move
up in the directory hierarchy). A file path is immutable; all instances that
modify a path return a new path instance.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DOT
The character sequence used to designate the current directory.
|
protected boolean |
m_isAbsolute
A flag that determines if the path is absolute.
|
protected java.util.List<java.lang.String> |
m_parts
The elements of the path.
|
static java.lang.String |
SLASH
The character used to separate path parts.
|
static java.lang.String |
UP
The character sequence used to designate the "up" direction.
|
| Constructor and Description |
|---|
FilePath(java.util.List<java.lang.String> parts,
boolean is_absolute)
Creates a file path from a list of path elements.
|
FilePath(java.lang.String path)
Creates a file path by parsing a string.
|
| Modifier and Type | Method and Description |
|---|---|
java.nio.file.Path |
asPath()
Produces a Java
Path object corresponding to the current file
path. |
FilePath |
chdir(FilePath path)
Obtains a path instance relative to the current path.
|
FilePath |
chdir(java.lang.String path)
Obtains a path instance relative to the current path.
|
static java.util.List<java.lang.String> |
fragment(java.lang.String path)
Splits a string into path fragments according to the path separator.
|
boolean |
isAbsolute()
Determines if this path is an absolute path.
|
static java.util.List<java.lang.String> |
simplify(java.util.List<java.lang.String> parts)
Simplifies a list of path parts.
|
java.lang.String |
toString() |
public static final java.lang.String SLASH
public static final java.lang.String UP
public static final java.lang.String DOT
protected final java.util.List<java.lang.String> m_parts
protected final boolean m_isAbsolute
public FilePath(java.util.List<java.lang.String> parts,
boolean is_absolute)
parts - The list of path elementsis_absolute - A flag indicating if the path is an absolute onepublic FilePath(java.lang.String path)
path - The string containing the pathpublic boolean isAbsolute()
public FilePath chdir(FilePath path)
path - A string corresponding to the path relative to the current
pathpublic FilePath chdir(java.lang.String path)
path - A string corresponding to the path relative to the current
pathpublic java.nio.file.Path asPath()
Path object corresponding to the current file
path.public java.lang.String toString()
toString in class java.lang.Objectpublic static java.util.List<java.lang.String> fragment(java.lang.String path)
path - The stringpublic static java.util.List<java.lang.String> simplify(java.util.List<java.lang.String> parts)
parts - The list of partsCopyright © Sylvain HallĂ©. All Rights Reserved.