Here you can find the source of getAllHostIPs(String hostName)
public static List<String> getAllHostIPs(String hostName)
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getAllHostIPs(String hostName) { List<String> ips = null; try {/*ww w . j a va 2s .co m*/ InetAddress[] addrs = InetAddress.getAllByName(hostName); if (null != addrs && addrs.length > 0) { ips = new ArrayList<String>(); for (int i = 0; i < addrs.length; i++) { ips.add(addrs[i].getHostAddress()); } } } catch (Exception e) { e.printStackTrace(); } return ips; } }