Java examples for Network:Network Address
get Inet Socket Address
//package com.java2s; import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] argv) throws Exception { String address = "java2s.com"; System.out.println(getInetSocketAddress(address)); }// w ww.j a v a2 s . c om public static List<InetSocketAddress> getInetSocketAddress( String address) { List<InetSocketAddress> inetSocketAddresses = new ArrayList<InetSocketAddress>(); String[] addresses = address.split(","); for (String dress : addresses) { String[] hosts = dress.split(":"); inetSocketAddresses.add(new InetSocketAddress(hosts[0], Integer .parseInt(hosts[1]))); } return inetSocketAddresses; } }