public abstract class Addresses extends Object
Constructor and Description |
---|
Addresses() |
Modifier and Type | Method and Description |
---|---|
static void |
clearCaches() |
static SortedSet<String> |
getAddresses() |
static SortedSet<String> |
getAddresses(boolean includeLocal,
boolean includeIPv6)
Warning: When includeLocal is false,
all returned addresses should be routable, but they are not necessarily
appropriate for external use.
|
static SortedSet<String> |
getAddresses(boolean includeSiteLocal,
boolean includeLoopbackAndWildcard,
boolean includeIPv6)
Warning: When includeSiteLocal and includeLoopbackAndWildcard are false,
all returned addresses should be routable, but they are not necessarily
appropriate for external use.
|
static SortedSet<String> |
getAllAddresses() |
static String |
getAnyAddress() |
static byte[] |
getIP(String host)
Caching version of InetAddress.getByName(host).getAddress(), which is slow.
|
static byte[] |
getIP(String host,
boolean preferIPv6)
For literal IP addresses, this is the same as getIP(String).
|
static List<byte[]> |
getIPs(String host)
For literal IP addresses, this is the same as getIP(String).
|
static int |
getPort(String port)
Convenience method to convert and validate a port String
without throwing an exception.
|
static boolean |
isConnected()
Do we have any non-loop, non-wildcard IPv4 address at all?
|
static boolean |
isConnectedIPv6()
Do we have any non-loop, non-wildcard IPv6 address at all?
|
static boolean |
isDeprecated(Inet6Address addr)
Is this address deprecated?
Returns false if unknown.
|
static boolean |
isDynamic(Inet6Address addr)
Is this address dynamic?
Returns false if unknown.
|
static boolean |
isTemporary(Inet6Address addr)
Is this address temporary?
Returns false if unknown.
|
static void |
main(String[] args)
Print out the local addresses
|
static String |
toString(byte[] addr)
Convenience method to convert an IP address to a String
without throwing an exception.
|
static String |
toString(byte[] addr,
int port)
Convenience method to convert an IP address and port to a String
without throwing an exception.
|
public static boolean isConnected()
public static boolean isConnectedIPv6()
public static String getAnyAddress()
public static SortedSet<String> getAddresses()
public static SortedSet<String> getAllAddresses()
public static SortedSet<String> getAddresses(boolean includeLocal, boolean includeIPv6)
includeLocal
- whether to include localincludeIPv6
- whether to include IPV6public static SortedSet<String> getAddresses(boolean includeSiteLocal, boolean includeLoopbackAndWildcard, boolean includeIPv6)
includeSiteLocal
- whether to include private like 192.168.x.xincludeLoopbackAndWildcard
- whether to include 127.x.x.x and 0.0.0.0includeIPv6
- whether to include IPV6public static String toString(byte[] addr)
public static String toString(byte[] addr, int port)
public static int getPort(String port)
public static byte[] getIP(String host)
host
- DNS or IPv4 or IPv6 host name; if null returns nullpublic static byte[] getIP(String host, boolean preferIPv6)
host
- DNS or IPv4 or IPv6 host name; if null returns nullpublic static List<byte[]> getIPs(String host)
host
- DNS or IPv4 or IPv6 host name; if null returns nullpublic static boolean isDynamic(Inet6Address addr)
public static boolean isDeprecated(Inet6Address addr)
public static boolean isTemporary(Inet6Address addr)
public static void clearCaches()
public static void main(String[] args)