URI Resolution
In this chapter you will learn:
Resolution
Resolution is the process of resolving one URI against another URI.
The resulting URI is constructed from components of both URIs.
Check http://tools.ietf.org/html/rfc2396
for the details.
Resolution of both absolute and relative URIs, and of both absolute and relative paths in the case of hierarchical URIs, is supported.
URI declares
URI resolve(String str)
and
URI resolve(URI uri)
methods for resolving the original URI argument against the base URI contained in the current URI object.
import java.net.URI;
import java.net.URISyntaxException;
//from j a v a 2 s. co m
public class Main {
public static void main(String[] args) throws URISyntaxException {
URI uri = new URI("http://java2s.com/");
System.out.println("Resolved URI = " + uri.resolve("/index.htm"));
}
}
Output:
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » URL URI