URI Resolve() Example
Constructs a new URI by parsing the given string and then resolving it against this URI.
URIclass Resolve() method example. This example shows you how to use Resolve() method.This method Constructs a new URI by parsing the given string and then resolving it against this URI.
Here is the code:-
/**
* @Program that Constructs a new URI by parsing the given string and then
* resolving it against this URI
* Resolve.java
* Author:-RoseIndia Team
* Date:-24-jun-2008
*/
import java.net.*;
public class Resolve {
public static void main(String[] args) throws Exception {
String scheme = "http";
String userInfo = "girish";
String host = "tewari.com";
int port = 8080;
String path = "/mail/";
String query = "open";
String fragment = "inbox";
URI uri = new URI(scheme, userInfo, host, port, path, query, fragment);
//Constructs a new URI by parsing the given string
System.out.println("Given new URI is: " + uri.resolve("//java.sun.com/javase/6/docs/api/"));
}
} |
Output of the program:-
| Given new URI is: http://java.sun.com/javase/6/docs/api/ |
|