Package: org.gradle.api.file

## [Java] Class RelativePath

- org.gradle.api.file.RelativePath

- All Implemented Interfaces and Traits:
    Serializable

      public class RelativePath

  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 Summary

    Constructors
    Constructor and description
    `RelativePath (boolean endsWithFile, String... segments)` Creates a `RelativePath`.

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `RelativePath` | `append(RelativePath other)`
    `RelativePath` | `append(boolean endsWithFile, String... segments)` Appends the given names 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, 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()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Constructor Detail

    - #### public RelativePath(boolean endsWithFile, String... segments)

      Creates a `RelativePath`.

      Parameters:
        `endsWithFile` - - if true, the path ends with a file, otherwise a directory

  - ### Method Detail

    - #### public RelativePath append(RelativePath other)

      Appends the given path to the end of this path.

      Parameters:
        `other` - The path to append
      Returns:
        The new path

    - #### public RelativePath append(boolean endsWithFile, String... segments)

      Appends the given names to the end of this path.

      Parameters:
        `segments` - The names to append.
        `endsWithFile` - when true, the new path refers to a file.
      Returns:
        The new path.

    - #### @Override public boolean equals(Object o)

    - #### public File getFile(File baseDir)

    - #### public String getLastName()

    - #### public RelativePath getParent()

      Returns the parent of this path.

      Returns:
        The parent of this path, or null if this is the root path.

    - #### public String getPathString()

    - #### public String[] getSegments()

    - #### @Override public int hashCode()

    - #### public boolean isFile()

    - #### public static RelativePath parse(boolean isFile, String path)

    - #### public static RelativePath parse(boolean isFile, RelativePath parent, String path)

    - #### public RelativePath plus(RelativePath other)

      Appends the given path to the end of this path.

      Parameters:
        `other` - The path to append
      Returns:
        The new path

    - #### public RelativePath prepend(String... segments)

      Prepends the given names to the start of this path.

      Parameters:
        `segments` - The names to prepend
      Returns:
        The new path.

    - #### public RelativePath replaceLastName(String name)

      Returns a copy of this path, with the last name replaced with the given name.

      Parameters:
        `name` - The name.
      Returns:
        The path.

    - #### public ListIterator<String> segmentIterator()

    - #### @Override public String toString()