code: public URI toURI()
     {
        try {
           URI uri = new URI(toURL());
           return uri;
        }
        catch (URISyntaxException e) {
           throw new IllegalStateException("URL cannot be parsed.", e);
        }
     }
docs: Return a URI representation of this URL including path and query string