URI uri = new URI("http://www.example.com/path/file.html");
String scheme = uri.getScheme(); // returns "http" String host = uri.getHost(); // returns "www.example.com" String path = uri.getPath(); // returns "/path/file.html"
URI baseUri = new URI("http://www.example.com/path/"); URI relativeUri = new URI("file.html"); URI resolvedUri = baseUri.resolve(relativeUri);
URL url = uri.toURL();This converts the URI to a URL object. The java.net.URI class is part of the Java SE library, specifically the "java.net" package.