List of utility methods to do Host Name Get
Set | getAllMyHostAdresses() get All My Host Adresses Set<InetAddress> addresses = new HashSet<InetAddress>(); Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); while (en.hasMoreElements()) { Enumeration<InetAddress> ias = en.nextElement().getInetAddresses(); while (ias.hasMoreElements()) addresses.add(ias.nextElement()); return addresses; ... |
InetAddress | getByName(String host) get By Name if (host == null) throw new NullPointerException("can't lookup null host"); return InetAddress.getByName(host); |
String | getCanonicalHostName() get Canonical Host Name return localhost.getCanonicalHostName();
|
String | getCanonicalHostname() Gets the canonical hostname of this machine. return InetAddress.getLocalHost().getCanonicalHostName();
|
String | getCanonicalHostName() Will return FQDN of the host after doing reverse DNS lookip. try { return InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException e) { return LOCALHOST; |
String | getCanonicalHostName() get Canonical Host Name String result = new String(); try { Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); String eth0 = ""; String wlan0 = ""; while (en.hasMoreElements()) { NetworkInterface intf = en.nextElement(); Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); ... |
String | getCanonicalHostName() Returns the fully-qualified domain name of the local host in all lower case. try { return getExternalAddressOfLocalSystem().getCanonicalHostName().toLowerCase(); } catch (UnknownHostException e) { throw new RuntimeException(e); |
String | getCasServerHostName() Gets cas server host name. try { final String hostName = InetAddress.getLocalHost().getCanonicalHostName(); final int index = hostName.indexOf('.'); if (index > 0) { return hostName.substring(0, index); return hostName; } catch (final Exception e) { ... |
String | getCurrentHost() get Current Host String hostname = "localhost"; try { hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { e.printStackTrace(); return hostname; |
String | getDefaultHostName() Returns the default host name. try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { String host = System.getenv("COMPUTERNAME"); if (host != null) { return host; host = System.getenv("HOSTNAME"); if (host != null) { return host; return ""; |