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