List of utility methods to do Local Host Get
String | getLocalHostAddress() Returns the real IP Address of the NIC for the localhost. try { return InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { throw new RuntimeException(e); |
String | getLocalHostAddress() Gets the set localhost address as URL string (ipv6 addresses are enclosed in []) byte[] addr = localhost.getAddress(); String localHostAddress = localhost.getHostAddress().replaceAll("%10", ""); if (addr.length == 16) { localHostAddress = "[" + localHostAddress + "]"; return localHostAddress; |
String | getLocalhostAddress() get Localhost Address String localhostAdress = null; try { final InetAddress localHost = InetAddress.getLocalHost(); if (localHost != null) { localhostAdress = localHost.getHostAddress(); } catch (UnknownHostException ex) { return localhostAdress; |
byte[] | getLocalHostID() Generates an array of 6-bytes that is a fairly reliable identifier of the system on which this code is running. try { Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces(); byte[] candidateAddress = null; for (; netInterfaces.hasMoreElements();) { candidateAddress = netInterfaces.nextElement().getHardwareAddress(); if (!suspiciousHardwareAddress(candidateAddress)) break; else ... |
InetAddress | getLocalHostLANAddress() get Local Host LAN Address try { InetAddress candidateAddress = null; for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements();) { NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); for (Enumeration inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) { InetAddress inetAddr = (InetAddress) inetAddrs.nextElement(); if (!inetAddr.isLoopbackAddress()) { if (inetAddr.isSiteLocalAddress()) { ... |
String | getLocalHostName() get Local Host Name if (host_ == null) { host_ = getLocalAddress().getCanonicalHostName(); return host_; |
String | getLocalHostName() get Local Host Name if (localHostName == null) { init(); return localHostName; |
String | getLocalHostName() Get local host name. String sLocalHostName; try { sLocalHostName = InetAddress.getLocalHost().getHostName(); } catch (Exception e) { sLocalHostName = "127.0.0.1"; return sLocalHostName; |
String | getLocalHostName() best effort method to determine host name of localhost. try { final String name = InetAddress.getLocalHost().getCanonicalHostName(); if (name == null || name.length() == 0) { return "localhost"; } else if (name.equals(InetAddress.getLocalHost().getHostAddress())) { return "localhost"; } else { return name; ... |
String | getLocalHostName() Get this computer's name. try { java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost(); return localMachine.getHostName(); } catch (java.net.UnknownHostException uhe) { System.out.println(uhe.toString()); return ""; |