Here you can find the source of getHost(URI uri)
public static String getHost(URI uri)
//package com.java2s; //License from project: Apache License import java.net.*; public class Main { public static String getHost(URI uri) { String host = uri.getHost(); int port = uri.getPort(); if (port != -1) { host += ":" + port; }/*ww w . ja va 2 s . c om*/ return host; } public static int getPort(URI uri) { int port = uri.getPort(); if (port == -1) { if ("https".equals(uri.getScheme())) port = 443; else port = 80; } return port; } }