Java URI Create uri(String value)

Here you can find the source of uri(String value)

Description

uri

License

Apache License

Declaration

public static URI uri(String value) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.net.URI;
import java.net.URISyntaxException;

public class Main {
    public static URI uri(String value) {
        try {//  w w w. java  2 s.  c  om
            return new URI(value);
        } catch (URISyntaxException e) {
            e.printStackTrace();
            throw new IllegalArgumentException("Invalid URI: " + value);
        }
    }

    public static URI uri(URI parent, String relative) {
        if (!relative.startsWith("/")) {
            relative = "/" + relative;
        }

        if (parent.toString().contains("#")) {
            return uri(parent.toString() + relative);
        } else {
            return uri(parent.toString() + "#" + relative);
        }
    }
}

Related

  1. uri(String path)
  2. uri(String str)
  3. uri(String uri)
  4. uri(String uri)
  5. uri(String uriStr)
  6. uri(String value)
  7. uri(URI uri)