Java URI from toURI(String str)

Here you can find the source of toURI(String str)

Description

Constructs URI from given string.

License

Apache License

Declaration

public static URI toURI(String str) 

Method Source Code

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

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

public class Main {
    /**/*from   www  . j  a  va  2 s. co m*/
     * Constructs <code>URI</code> from given string.
     * <p/>
     * The <code>URISyntaxException</code> is rethrown as
     * <code>IllegalArgumentException</code>
     */
    public static URI toURI(String str) {
        try {
            return new URI(str);
        } catch (URISyntaxException ex) {
            throw new IllegalArgumentException(ex);
        }
    }

    /**
     * Constructs <code>URI</code> from given <code>URL</code>.
     * <p/>
     * The <code>URISyntaxException</code> is rethrown as
     * <code>IllegalArgumentException</code>
     */
    public static URI toURI(URL url) {
        try {
            return url.toURI();
        } catch (URISyntaxException ex) {
            throw new IllegalArgumentException(ex);
        }
    }
}

Related

  1. toURI(String location)
  2. toURI(String location)
  3. toUri(String path)
  4. toURI(String path)
  5. toURI(String s)
  6. toURI(String str)
  7. toURI(String sUri)
  8. toURI(String uri)
  9. toUri(String uri)