Here you can find the source of addressToString(InetSocketAddress address, Boolean useIpAddress)
public static String addressToString(InetSocketAddress address, Boolean useIpAddress)
//package com.java2s; //License from project: Apache License import java.net.*; public class Main { public static String addressToString(InetSocketAddress address, Boolean useIpAddress) { if (useIpAddress) { return "http://" + address.getAddress().getHostAddress() + ":" + address.getPort(); } else {//ww w . j av a 2 s .c om return "http://" + address.getAddress().getHostName() + ":" + address.getPort(); } } }