Java URI to Relative URI relativize(URI baseURI, URI uriToRelativize)

Here you can find the source of relativize(URI baseURI, URI uriToRelativize)

Description

relativize

License

Open Source License

Declaration

public static URI relativize(URI baseURI, URI uriToRelativize) 

Method Source Code


//package com.java2s;
import java.io.*;
import java.net.*;

public class Main {
    public static URI relativize(URI baseURI, URI uriToRelativize) {
        URI relativizedURI;/* w  w w.java 2  s  .c  o m*/
        if (baseURI == null) {
            relativizedURI = uriToRelativize;
        } else {
            try {
                File file = new File(baseURI);
                if (!file.isDirectory()) {
                    File parent = file.getParentFile();
                    baseURI = parent.toURI();
                }
            } catch (IllegalArgumentException e) {
                // do nothing, not a file uri
            }
            relativizedURI = baseURI.relativize(uriToRelativize);
        }
        return relativizedURI;
    }
}

Related

  1. relativize(URI base, URI child)
  2. relativize(URI base, URI child)
  3. relativize(URI base, URI target)
  4. relativize(URI basePath, File path)
  5. relativize(URI baseUri, File f)
  6. relativizeFromBase(String uri, URI base)
  7. resolve(String baseURI, String connectorURI)
  8. resolve(String path, URI... relativeTo)
  9. resolve(URI base, URI child)