Here you can find the source of toURI(String str)
URI
from given string.
public static URI toURI(String str)
//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); } } }