Here you can find the source of toString(InetSocketAddress addr)
public static String toString(InetSocketAddress addr)
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.InetSocketAddress; public class Main { public static String toString(InetSocketAddress addr) { if (addr == null) { return null; }// w w w . jav a 2 s .c o m if (addr.isUnresolved()) { return addr.getHostString() + ':' + addr.getPort(); } else { InetAddress ia = addr.getAddress(); return ia.getHostAddress() + ':' + addr.getPort(); } } }