Java IP Address Get getIPList(String address)

Here you can find the source of getIPList(String address)

Description

get IP List

License

Open Source License

Declaration

public static Set<String> getIPList(String address) 

Method Source Code

//package com.java2s;
/**/*from www. j  a  v a  2  s .  c  o  m*/
 * Copyright (C) 2013 CLXY Studio.
 * This content is released under the (Link Goes Here) MIT License.
 * http://en.wikipedia.org/wiki/MIT_License
 */

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static Set<String> getIPList(String address) {

        Set<String> ips = new HashSet<>();

        try {
            InetAddress[] machines = InetAddress.getAllByName(address);
            for (InetAddress machine : machines) {
                ips.add(machine.getHostAddress());
            }
        } catch (UnknownHostException e) {
            // Do nothing, just return empty result.
        }
        return ips;
    }
}

Related

  1. getIpByNetworkInterfaceName(String name)
  2. getIPFromHash(final long ipHash)
  3. getIPFromInterface(String ni)
  4. getIPFromNetworkInterface()
  5. getIpHostnameLocal()
  6. getIPList(String s, String s1)
  7. getIPs()
  8. getIPs()
  9. getIPv4Address()