Java URI to Relative URI relativeURI(String basePath, String path)

Here you can find the source of relativeURI(String basePath, String path)

Description

Return the relative URI of the given path with respect to the given base path.

License

Open Source License

Parameter

Parameter Description
basePath The base path of the requested relative path
path The path of which the relative URI is requested

Declaration

public static URI relativeURI(String basePath, String path) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.net.URI;

public class Main {
    /**//from  w  w w.ja  va2 s. com
     * Return the relative URI of the given path with respect to
     * the given base path.
     * 
     * @param basePath The base path of the requested relative path
     * @param path The path of which the relative URI is requested
     */
    public static URI relativeURI(String basePath, String path) {
        return new File(basePath).toURI().relativize(new File(path).toURI());
    }
}

Related

  1. getRelativeUri(URI rootURI, File file)
  2. getRelativeURI(URI uri, URI relativeTo)
  3. relativeConfig(URI uri)
  4. relativeFileToURI(File file)
  5. relativePath(final URI baseURI, final URI pathURI)
  6. relativize(URI base, URI child)
  7. relativize(URI base, URI child)
  8. relativize(URI base, URI target)
  9. relativize(URI basePath, File path)