Here you can find the source of parseInetSocketAddress(String text)
public static InetSocketAddress parseInetSocketAddress(String text)
//package com.java2s; //License from project: Apache License import java.net.InetSocketAddress; public class Main { public static InetSocketAddress parseInetSocketAddress(String text) { if (text == null || text.isEmpty()) { throw new IllegalArgumentException("Address is empty"); }// w w w . j a va 2 s .c o m final int index = text.lastIndexOf(':'); if (index == -1 || index == text.length() - 1) { throw new IllegalArgumentException("Port is not found in: " + text); } if (index == 0) { throw new IllegalArgumentException("Host is not found in: " + text); } final String host = text.substring(0, index); final String portStr = text.substring(index + 1, text.length()); final int port; try { port = Integer.parseInt(portStr); } catch (NumberFormatException e) { throw new IllegalArgumentException("Port is not integer in address: " + text, e); } final InetSocketAddress address; try { address = new InetSocketAddress(host, port); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Failed to parse address: " + text, e); } return address; } }