Here you can find the source of socketAddress2String(final SocketAddress addr)
public static String socketAddress2String(final SocketAddress addr)
//package com.java2s; //License from project: Apache License import java.net.InetSocketAddress; import java.net.SocketAddress; public class Main { public static String socketAddress2String(final SocketAddress addr) { StringBuilder sb = new StringBuilder(); InetSocketAddress inetSocketAddress = (InetSocketAddress) addr; sb.append(inetSocketAddress.getAddress().getHostAddress()); sb.append(":"); sb.append(inetSocketAddress.getPort()); return sb.toString(); }/*from w w w . j a va 2 s. c o m*/ }