Java URI Create createURI(String uri)

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

Description

Convenience method to turn a String into a URI without throwing any pesky checked exceptions.

License

LGPL

Parameter

Parameter Description
uri URI text

Exception

Parameter Description
IllegalArgumentException if uri doesn't look like a URI

Return

URI

Declaration

public static URI createURI(String uri) 

Method Source Code

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

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

public class Main {
    /**//w  w w .  j  av a 2 s .co m
     * Convenience method to turn a String into a URI without throwing
     * any pesky checked exceptions.
     * 
     * @param  uri  URI text
     * @return  URI
     * @throws  IllegalArgumentException   if uri doesn't look like a URI
     */
    public static URI createURI(String uri) {
        try {
            return new URI(uri);
        } catch (URISyntaxException e) {
            throw (IllegalArgumentException) new IllegalArgumentException("Bad URI: " + uri).initCause(e);
        }
    }
}

Related

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