Java实现从IP和端口列表List获取分离的IP和端口值

List<String> addrList = getFromSomeWhere();
InetSocketAddress[] addrs = new InetSocketAddress[addrList.length()];
for (int i = 0; i < addrList.length(); ++i) {
	String[] parts = addrList.get(i).split("\\:", 2);
	if (parts.length != 2) {
		// Your code for tackling this error.
	}
	addrs[i] = new InetSocketAddress(part[0].trim(), part[1].trim());
}



原文链接: http://blog.csdn.net/poechant/article/details/6983097

你可能感兴趣的:(Java实现从IP和端口列表List获取分离的IP和端口值)