Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8356319

No way to extract a relative URI path string from a relative Path

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      The `Path.toUri()` method is specified to return an absolute URI always. However, sometimes what you want is a relative URI with a relative path that corresponds to the file path, for the purpose of either extracting a path with platform-neutral separators, or for the raw path which is URI-encoded.

      There seem to be several not-so-great solutions to this problem, but ideally there would just be a way to acquire a relative URI directly from the `Path`. Either via `toRelativeUri()` default method on `URI`, or maybe a static method on `Path` or `Paths`. Note that absolute paths can yield a relative URI with an absolute path component as a relative URI is defined merely as one with no scheme component.

            Unassigned Unassigned
            tongwan Andrew Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: