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());
}


你可能感兴趣的:(java,list,String)