Java URI class

Description

Java URI class


import java.net.URI;
import java.net.URISyntaxException;

public class Main {
  public static void main(String[] args) {
    URI baseURI;/*from  w  ww.j av  a  2s . co  m*/
    try {
      baseURI = new URI("https://www.demo2s.com");
      // Create a URI with relative URI string and resolve it using baseURI
      URI relativeURI = new URI("welcome.html");
      URI resolvedRelativeURI = baseURI.resolve(relativeURI);
      System.out.println(resolvedRelativeURI);
    } catch (URISyntaxException e) {  
      e.printStackTrace();
    }

  }
}



PreviousNext

Related