Create url object with properties in java

package com.w3spoint;
 
import java.net.MalformedURLException;
import java.net.URL;
 
public class URLTest {
  public static void main(String args[]){
	try {
	    String protocol = "https";
            String host = "w3spoint.com";
            int port = 8080;
            String path = "/object-oriented-design-principles-in-java-examples/";
            URL url = new URL(protocol, host, port, path);
            System.out.println(url.toString());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
  }
}

Output

https://826.a00.myftpupload.com:8080/object-oriented-design-principles-in-java-examples/
Content Protection by DMCA.com
Please Share