Here you can find the source of getHostAndPort(URI u)
private static String getHostAndPort(URI u)
//package com.java2s; //License from project: Apache License import java.net.URI; public class Main { private static String getHostAndPort(URI u) { String host = u.getHost(); int port = u.getPort(); return port < 1 ? host : host + ":" + port; }/*from w w w . j av a2 s . c om*/ }