Here you can find the source of getAddress(SocketAddress address)
public static String getAddress(SocketAddress address)
//package com.java2s; //License from project: Apache License import java.net.*; public class Main { public static String getAddress(SocketAddress address) { if (address == null) { return null; }/* w w w . j a v a 2s .com*/ if (address instanceof InetSocketAddress) { InetSocketAddress isa = (InetSocketAddress) address; return isa.getAddress().getHostAddress() + ":" + isa.getPort(); } else { return address.toString(); } } }