Here you can find the source of cast2SocketAddress(String addr)
public static SocketAddress cast2SocketAddress(String addr)
//package com.java2s; //License from project: Apache License import java.net.InetSocketAddress; import java.net.SocketAddress; public class Main { public static SocketAddress cast2SocketAddress(String addr) { String[] str = addr.split(":"); if (str.length != 2) throw new IllegalArgumentException(); return new InetSocketAddress(str[0], Integer.valueOf(str[1])); }/*from w w w . ja v a2 s . c om*/ public static SocketAddress cast2SocketAddress(long id) { StringBuffer host = new StringBuffer(30); host.append((id & 0xff)).append('.'); host.append(((id >> 8) & 0xff)).append('.'); host.append(((id >> 16) & 0xff)).append('.'); host.append(((id >> 24) & 0xff)); int port = (int) ((id >> 32) & 0xffff); return new InetSocketAddress(host.toString(), port); } }