List of utility methods to do Host Address Get
String | getHostAddress(boolean promiscuous) Returns the string "127.0.0.1". String addr = "127.0.0.1"; try { if (JAVABRIDGE_PROMISCUOUS || promiscuous) addr = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { return addr; |
String | getHostAddress(final String name) Return the local host address for a passed in host using java.net.InetAddress#getByName(String) return InetAddress.getByName(name).getHostAddress();
|
InetAddress | getHostAddress(String hostname) Get the Inet address of the machine of the given host name. InetAddress serverIPAddress; if (hostname != null && !hostname.isEmpty()) { serverIPAddress = InetAddress.getByName(hostname); } else { serverIPAddress = InetAddress.getLocalHost(); return serverIPAddress; |
InetAddress | getHostAddress(String hostPort) Gets the host name from a host:port. String host = getHost(hostPort);
return (host == null) ? null : InetAddress.getByName(host);
|
InetAddress[] | getHostAddresses() get Host Addresses try { String hname = getHostName(); if (hname == null) { return null; return InetAddress.getAllByName(hname); } catch (Exception e) { return null; ... |
String[] | getHostAddresses() get Host Addresses Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces(); List<String> hostIps = new ArrayList<String>(); while (nifs.hasMoreElements()) { NetworkInterface nif = (NetworkInterface) nifs.nextElement(); Enumeration<InetAddress> ips = nif.getInetAddresses(); while (ips.hasMoreElements()) { InetAddress ip = (InetAddress) ips.nextElement(); if (ip instanceof java.net.Inet4Address) { ... |
List | getHostAddresses() get Host Addresses List<String> result = new ArrayList<>(); Enumeration e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) { NetworkInterface n = (NetworkInterface) e.nextElement(); Enumeration ee = n.getInetAddresses(); while (ee.hasMoreElements()) { InetAddress i = (InetAddress) ee.nextElement(); if (i instanceof Inet6Address || i ... |
String | getHostAddressFromProperty(final String property) Return the local host address based on the value of a system property. return getInetAddressFromProperty(property).getHostAddress();
|
String | getHostExternalAddr() get Host External Addr try { Enumeration e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) { NetworkInterface n = (NetworkInterface) e.nextElement(); Enumeration ee = n.getInetAddresses(); while (ee.hasMoreElements()) { InetAddress i = (InetAddress) ee.nextElement(); if (!i.getHostAddress().startsWith("192") && !i.getHostAddress().startsWith("127")) { ... |
String | getHostName(String addr) get Host Name if (!isRawAddress(addr)) return addr; try { return InetAddress.getByAddress(toRawAddress(addr)).getHostName(); } catch (UnknownHostException e) { return addr; |