List of utility methods to do Host Resolve
URI | resolve(String host, String path) resolve URI uri = null; try { uri = new URI(host); uri = uri.resolve(path); } catch (URISyntaxException e) { e.printStackTrace(); return null; return uri; |
String | resolveHost(String hostname) Resolves hostname and returns ip address as a string. try { InetAddress addr = InetAddress.getByName(hostname); byte[] ipAddr = addr.getAddress(); StringBuilder ipAddrStr = new StringBuilder(15); for (int i = 0; i < ipAddr.length; i++) { if (i > 0) ipAddrStr.append('.'); ipAddrStr.append(ipAddr[i] & 0xFF); ... |
String | resolveHostname() Helper utility that calls into the InetAddress system to resolve the hostname. try { return InetAddress.getLocalHost().getCanonicalHostName(); } catch (java.net.UnknownHostException uhe) { return "unresolvable"; |
String | resolveHostname() resolve Hostname InetAddress addr; try { addr = InetAddress.getLocalHost(); } catch (UnknownHostException uhe) { return "localhost"; return addr.getCanonicalHostName(); |
String | resolveHostName() Read hostName from JDK. try { if (useInetAddress) { return InetAddress.getLocalHost().getHostName(); throw new UnknownHostException("Do not use the Inet Adress"); } catch (UnknownHostException e) { throw new IllegalArgumentException("Cannot find the target host by itself", e); |
String | resolveHostName(final String hostName) Resolves the host name and returns its IP address. InetAddress address = null;
address = InetAddress.getByName(hostName);
return address.getHostAddress();
|
String | resolveHostName(String hostname) Resolves a given hostname by a canonical hostname. if (hostname == null || hostname.isEmpty()) { return null; return InetAddress.getByName(hostname).getCanonicalHostName(); |