Class ExtractPathElementRange

Object
ExtractPathElementRange

public class ExtractPathElementRange extends Object
Extracts a range of elements from a Path.
Author:
Owen Feehan
  • Method Details

    • extract

      public static Path extract(Path path, IndexRangeNegative range) throws DerivePathException
      Extracts a sub-path from a Path by only retaining a range of elements.

      The name-elements are a split of the Path by the directory-separator. See the Path Javadoc.

      All indices begin at 0 (for the first element), and can also accept negative-indices which count backwards from the end.

      e.g. -1 is the last element; -2 is the second-last element.

      Parameters:
      path - the path to find a sub-path for.
      range - which elements to include or not.
      Returns:
      a newly created Path containing only the elements of path in the sub-range.
      Throws:
      DerivePathException - if the range contains invalid indices.