Resolve a relative URLTag(s): Networking


import java.net.URL;

public class ResolveRelativeURL {
  public static void main (String[] args) throws
       java.net.MalformedURLException {
    URL relativeURL, baseURL;
    baseURL = new URL ("http://www.rgagnon.com/");
    relativeURL = new URL ( baseURL, "./javadetails/java-0001.html");
    System.out.println ( relativeURL.toExternalForm ());
    /*
      output :
       http://www.rgagnon.com/javadetails/java-0001.html
    */    
  }
}

blog comments powered by Disqus