Here you can find the source of getInetSocketAddress(String s, String mainHost)
private static InetSocketAddress getInetSocketAddress(String s, String mainHost)
//package com.java2s; import java.net.InetSocketAddress; public class Main { private static InetSocketAddress getInetSocketAddress(String s, String mainHost) { int finalColon = mainHost.lastIndexOf(':'); if (finalColon < 1) { throw new IllegalArgumentException("Invalid server ``" + mainHost + "'' in list: " + s); }//from w w w . j a v a 2s.c o m String hostPart = mainHost.substring(0, finalColon).trim(); String portNum = mainHost.substring(finalColon + 1).trim(); InetSocketAddress mainAddress = new InetSocketAddress(hostPart, Integer.parseInt(portNum)); return mainAddress; } }