Here you can find the source of toInetSocketAddress(String hostPortPair, int defaultPort)
public static InetSocketAddress toInetSocketAddress(String hostPortPair, int defaultPort)
//package com.java2s; //License from project: Apache License import java.net.InetSocketAddress; public class Main { public static InetSocketAddress toInetSocketAddress(String hostPortPair, int defaultPort) { String[] split = hostPortPair.split(":"); String hostname = split[0]; int port; if (split.length > 1) { port = Integer.parseInt(split[1]); } else {/*w ww. j a v a2s .c o m*/ port = defaultPort; } InetSocketAddress inetSocketAddress = new InetSocketAddress(hostname, port); return inetSocketAddress; } }