Get Resolve a relative URL in Java
Description
The following code shows how to get Resolve a relative URL.
Example
import java.net.URL;
/*from w ww . j a va2 s . c o m*/
public class Main {
public static void main(String[] argv) throws Exception {
URL relativeURL, baseURL;
baseURL = new URL("http://www.yourserver.com/");
relativeURL = new URL(baseURL, "./a.htm");
System.out.println(relativeURL.toExternalForm());
}
}
The code above generates the following result.