public class RelativePath extends Object implements Serializable
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.
コンストラクタと説明 |
---|
RelativePath(boolean endsWithFile,
String... segments)
Creates a
RelativePath . |
修飾子とタイプ | メソッドと説明 |
---|---|
RelativePath |
append(boolean endsWithFile,
String... segments)
Appends the given names to the end of this path.
|
RelativePath |
append(RelativePath other)
Appends the given path to the end of this path.
|
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,
RelativePath parent,
String path) |
static RelativePath |
parse(boolean isFile,
String path) |
RelativePath |
plus(RelativePath other)
Appends the given path to the end of this path.
|
RelativePath |
prepend(String... segments)
Prepends the given names to the start of this path.
|
RelativePath |
replaceLastName(String name)
Returns a copy of this path, with the last name replaced with the given name.
|
ListIterator<String> |
segmentIterator() |
String |
toString() |
public RelativePath(boolean endsWithFile, String... segments)
RelativePath
.endsWithFile
- - if true, the path ends with a file, otherwise a directorypublic String[] getSegments()
public ListIterator<String> segmentIterator()
public boolean isFile()
public String getPathString()
public String getLastName()
public RelativePath getParent()
public static RelativePath parse(boolean isFile, String path)
public static RelativePath parse(boolean isFile, RelativePath parent, String path)
public RelativePath replaceLastName(String name)
Returns a copy of this path, with the last name replaced with the given name.
name
- The name.public RelativePath append(RelativePath other)
Appends the given path to the end of this path.
other
- The path to appendpublic RelativePath plus(RelativePath other)
Appends the given path to the end of this path.
other
- The path to appendpublic RelativePath append(boolean endsWithFile, String... segments)
segments
- The names to append.endsWithFile
- when true, the new path refers to a file.public RelativePath prepend(String... segments)
segments
- The names to prepend