List of utility methods to do Local Host Get
byte[] | createLocalHostID(int size) Generates a byte array of the given size that should be a value unique to the host on which the current Java virtual machine is running. if (size < 0) throw new NegativeArraySizeException( "Cannot create a unique host ID value with a negative array size."); byte[] hostAddress = null; String hostname = null; try { InetAddress hostInetAddress = java.net.InetAddress.getLocalHost(); hostAddress = hostInetAddress.getAddress(); ... |
List | getAllLocalHostNames() get All Local Host Names List<String> localNames = new ArrayList<String>(); Enumeration<NetworkInterface> e = null; try { e = NetworkInterface.getNetworkInterfaces(); } catch (SocketException exception) { throw new RuntimeException(exception); for (; e.hasMoreElements();) { ... |
String | getCanonicalLocalHostName() Returns canonical name (fully qualified domain name) of the localhost. try { final InetAddress localHost = InetAddress.getLocalHost(); return localHost.getCanonicalHostName(); } catch (final UnknownHostException ex) { return "localhost"; |
String | getCanonicalLocalHostName() get Canonical Local Host Name try { InetAddress localhost = InetAddress.getLocalHost(); return localhost.getCanonicalHostName(); } catch (UnknownHostException e) { return getLocalAddressAsString(); |
InetAddress | getLocalHost() Get a cached copy of the local host. if (localHost == null) { try { localHost = InetAddress.getLocalHost(); } catch (UnknownHostException e) { localHost = InetAddress.getByName(LOCALHOST); return localHost; ... |
InetAddress | getLocalHost() Gets the set localhost address return localhost;
|
String | getLocalhost() Gets the hostname of localhost String hostname = null; try { InetAddress addr = InetAddress.getLocalHost(); hostname = addr.getHostName(); } catch (UnknownHostException e) { throw new RuntimeException("[FileHelper] {getLocalhost}: Can't get local hostname"); return hostname; ... |
String | getLocalHost() get Local Host if (_localHost != null) return _localHost; try { InetAddress addr = InetAddress.getLocalHost(); _localHost = addr.getHostName(); } catch (Exception e) { _localHost = "127.0.0.1"; return _localHost; |
InetAddress | getLocalHost() get Local Host return InetAddress.getLocalHost();
|
InetSocketAddress | getLocalHost() get Local Host try { final InetSocketAddress addr; final InetAddress local = InetAddress.getLocalHost(); addr = new InetSocketAddress(local, 0); if (printLocalHost) { printLocalHost = false; System.out.println(); System.out.println("\t\tLocal host used in tests:"); ... |