Java Host Address Get getHostAddresses()

Here you can find the source of getHostAddresses()

Description

get Host Addresses

License

Apache License

Declaration

public static InetAddress[] getHostAddresses() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.InetAddress;

public class Main {
    public static InetAddress[] getHostAddresses() {
        try {//from   w w  w. jav a2  s.  com
            String hname = getHostName();

            if (hname == null) {
                return null;
            }

            return InetAddress.getAllByName(hname);
        } catch (Exception e) {
            return null;
        }
    }

    public static String getHostName() {
        try {
            return InetAddress.getLocalHost().getHostName();
        } catch (Exception e) {
            return null;
        }
    }
}

Related

  1. getHostAddress()
  2. getHostAddress(boolean promiscuous)
  3. getHostAddress(final String name)
  4. getHostAddress(String hostname)
  5. getHostAddress(String hostPort)
  6. getHostAddresses()
  7. getHostAddresses()
  8. getHostAddressFromProperty(final String property)
  9. getHostExternalAddr()