public class RelativePath extends Object
Represents a relative path from some base directory to a file. Used in file copying to represent both a source and target file path when copying files.
RelativePath instances are immutable.
| Constructor and description |
|---|
RelativePath
(boolean endsWithFile, String... segments)Creates a RelativePath. |
| Type | Name and description |
|---|---|
RelativePath |
append(RelativePath other) |
RelativePath |
append(boolean endsWithFile, String... segments)Appends the given names to the end of this path. |
int |
compareTo(RelativePath o) |
boolean |
equals(Object o) |
File |
getFile(File baseDir) |
String |
getLastName() |
RelativePath |
getParent()Returns the parent of this path. |
String |
getPathString() |
String[] |
getSegments() |
int |
hashCode() |
boolean |
isFile() |
static RelativePath |
parse(boolean isFile, String path) |
static RelativePath |
parse(boolean isFile, RelativePath parent, String path) |
RelativePath |
plus(RelativePath other) |
RelativePath |
prepend(String... segments)Prepends the given names to the start of this path. |
RelativePath |
replaceLastName(String name) |
ListIterator<String> |
segmentIterator() |
String |
toString() |
Creates a RelativePath.
endsWithFile - - if true, the path ends with a file, otherwise a directory
Appends the given path to the end of this path.
other - The path to appendAppends the given names to the end of this path.
segments - The names to append.endsWithFile - when true, the new path refers to a file.Returns the parent of this path.
Appends the given path to the end of this path.
other - The path to appendPrepends the given names to the start of this path.
segments - The names to prepend
Returns a copy of this path, with the last name replaced with the given name.
name - The name.