Java URI Create createUri(String uri)

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

Description

Creates a URI from the specified string without throwing a URISyntaxException.

License

Open Source License

Parameter

Parameter Description
uri The URI in string format

Return

The URI

Declaration

public static URI createUri(String uri) 

Method Source Code


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

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

public class Main {
    /** The empty URI **/
    public final static URI EMPTYURI = createUri("");

    /**//w w w.ja  v  a2 s.  c  om
     * Creates a URI from the specified string without throwing a <tt>URISyntaxException</tt>.
     * @param uri The URI in string format
     * @return The URI
     */
    public static URI createUri(String uri) {
        try {
            return new URI(uri);
        } catch (URISyntaxException e) {
            return EMPTYURI;
        }
    }
}

Related

  1. createURI(String path)
  2. createURI(String scheme, String host, String path)
  3. createURI(String spec)
  4. createUri(String sUri, String defaultSchema, int deafultPort)
  5. createUri(String u)
  6. createURI(String uri)
  7. createURI(String uri)
  8. createURI(String uri)
  9. createURIWithFull(final String scheme, final String userInfo, final String host, final int port, final String path, final String query, final String fragment)