Package org.apache.camel.util
Class InetAddressUtil
- java.lang.Object
-
- org.apache.camel.util.InetAddressUtil
-
public final class InetAddressUtil extends Object
Util class forInetAddress
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getLocalHostName()
When using theInetAddress.getHostName()
method in an environment where neither a proper DNS lookup nor an /etc/hosts entry exists for a given host, the following exception will be thrown:static String
getLocalHostNameSafe()
When using theInetAddress.getHostName()
method in an environment where neither a proper DNS lookup nor an /etc/hosts entry exists for a given host, the following exception will be thrown:
-
-
-
Method Detail
-
getLocalHostName
public static String getLocalHostName() throws UnknownHostException
When using theInetAddress.getHostName()
method in an environment where neither a proper DNS lookup nor an /etc/hosts entry exists for a given host, the following exception will be thrown:java.net.UnknownHostException: <hostname>: <hostname> at java.net.InetAddress.getLocalHost(InetAddress.java:1425) ...
Instead of just throwing an UnknownHostException and giving up, this method grabs a suitable hostname from the exception and prevents the exception from being thrown. If a suitable hostname cannot be acquired from the exception, only then is the UnknownHostException thrown.- Returns:
- the hostname
- Throws:
UnknownHostException
- is thrown if hostname could not be resolved
-
getLocalHostNameSafe
public static String getLocalHostNameSafe()
When using theInetAddress.getHostName()
method in an environment where neither a proper DNS lookup nor an /etc/hosts entry exists for a given host, the following exception will be thrown:java.net.UnknownHostException: <hostname>: <hostname> at java.net.InetAddress.getLocalHost(InetAddress.java:1425) ...
Instead of just throwing an UnknownHostException and giving up, this method grabs a suitable hostname from the exception and prevents the exception from being thrown. If a suitable hostname cannot be acquired from the exception, then null is returned- Returns:
- the hostname, or null if not possible to resolve
-
-