public final class Inet
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.net.Inet4Address |
INET4_ANY
The "any" address for IPv4.
|
static java.net.Inet4Address |
INET4_BROADCAST
The broadcast-all address for IPv4.
|
static java.net.Inet4Address |
INET4_LOOPBACK
The traditional loopback address for IPv4.
|
static java.net.Inet6Address |
INET6_ANY
The "any" address for IPv6.
|
static java.net.Inet6Address |
INET6_LOOPBACK
The loopback address for IPv6.
|
| Modifier and Type | Method and Description |
|---|---|
static java.net.NetworkInterface |
findInterfaceWithScopeId(java.lang.String scopeName) |
static java.lang.String |
getHostNameIfResolved(java.net.InetAddress inetAddress)
Get the host name of the given address, if it is resolved.
|
static java.net.Inet4Address |
getInet4Address(int s1,
int s2,
int s3,
int s4)
Get an IPv4 address from four integer segments.
|
static java.net.Inet6Address |
getInet6Address(int s1,
int s2,
int s3,
int s4,
int s5,
int s6,
int s7,
int s8)
Get an IPv6 address from eight integer segments.
|
static int |
getScopeId(java.net.InetAddress address)
Get the scope ID of the given address (if it is an IPv6 address).
|
static int |
getScopeId(java.net.NetworkInterface networkInterface) |
static int |
getScopeId(java.net.NetworkInterface networkInterface,
java.net.InetAddress compareWith) |
static int |
getScopeId(java.lang.String scopeName)
Attempt to get the scope ID of the given string.
|
static int |
getScopeId(java.lang.String scopeName,
java.net.InetAddress compareWith)
Attempt to get the scope ID of the given string.
|
static boolean |
isInet4Address(java.lang.String address)
Checks whether given String is a valid IPv4 address.
|
static boolean |
isInet6Address(java.lang.String address)
Checks whether given String is a valid IPv6 address.
|
static CidrAddress |
parseCidrAddress(java.lang.String address)
Parse a CIDR address into a
CidrAddress object. |
static java.net.Inet4Address |
parseInet4Address(java.lang.String address)
Parse an IPv4 address into an
Inet4Address object. |
static byte[] |
parseInet4AddressToBytes(java.lang.String address)
Converts IPv4 address from textual representation to bytes.
|
static java.net.Inet6Address |
parseInet6Address(java.lang.String string)
Parse an IPv6 address into an
Inet6Address object. |
static byte[] |
parseInet6AddressToBytes(java.lang.String address)
Converts IPv6 address from textual representation to bytes.
|
static java.net.InetAddress |
parseInetAddress(java.lang.String address)
Parse an IP address into an
InetAddress object. |
static byte[] |
parseInetAddressToBytes(java.lang.String address)
Converts an IP address from textual representation to bytes.
|
static java.net.Inet6Address |
toInet6Address(java.net.InetAddress inetAddress)
Get the IPv6 equivalent of the given address.
|
static java.lang.String |
toOptimalString(byte[] addressBytes)
Get the optimal string representation of the bytes of an IP address.
|
static java.lang.String |
toOptimalString(java.net.InetAddress inetAddress)
Get the optimal string representation of an IP address.
|
public static final java.net.Inet4Address INET4_ANY
public static final java.net.Inet4Address INET4_LOOPBACK
public static final java.net.Inet4Address INET4_BROADCAST
public static final java.net.Inet6Address INET6_ANY
public static final java.net.Inet6Address INET6_LOOPBACK
public static java.lang.String toOptimalString(java.net.InetAddress inetAddress)
inetAddress - the address (must not be null)null)public static java.lang.String toOptimalString(byte[] addressBytes)
addressBytes - the address bytes (must not be null)null)public static java.net.Inet6Address toInet6Address(java.net.InetAddress inetAddress)
inetAddress - the address to convert (must not be null)null)public static java.lang.String getHostNameIfResolved(java.net.InetAddress inetAddress)
null.inetAddress - the address to check (must not be null)null if the address has no host name and is unresolvedpublic static java.net.Inet4Address getInet4Address(int s1,
int s2,
int s3,
int s4)
s1 - the first segments2 - the second segments3 - the third segments4 - the fourth segmentnull)public static java.net.Inet6Address getInet6Address(int s1,
int s2,
int s3,
int s4,
int s5,
int s6,
int s7,
int s8)
0xffff).s1 - the first segments2 - the second segments3 - the third segments4 - the fourth segments5 - the fifth segments6 - the sixth segments7 - the seventh segments8 - the eighth segmentnull)public static boolean isInet6Address(java.lang.String address)
address - address textual representationtrue if address is a valid IPv6 address, false otherwisepublic static java.net.Inet6Address parseInet6Address(java.lang.String string)
Inet6Address object.string - the address to parsenull if the address is not validpublic static boolean isInet4Address(java.lang.String address)
address - address textual representationtrue if address is a valid IPv4 address, false otherwisepublic static java.net.Inet4Address parseInet4Address(java.lang.String address)
Inet4Address object.address - the address to parsenull if the address is not validpublic static java.net.InetAddress parseInetAddress(java.lang.String address)
InetAddress object.address - the address to parsenull if the address is not validpublic static CidrAddress parseCidrAddress(java.lang.String address)
CidrAddress object.address - the address to parsenull if the address is not validpublic static byte[] parseInet6AddressToBytes(java.lang.String address)
If given string doesn't represent valid IPv6 address, the method returns null.
address - address textual representationnull if the address is not validpublic static byte[] parseInet4AddressToBytes(java.lang.String address)
If given string doesn't represent valid IPv4 address, the method returns null.
This only supports decimal notation.
address - address textual representationnull if the address is not validpublic static byte[] parseInetAddressToBytes(java.lang.String address)
If given string doesn't represent valid IP address, the method returns null.
address - address textual representationnull if the address is not validpublic static int getScopeId(java.net.InetAddress address)
public static int getScopeId(java.lang.String scopeName)
scopeName - the scope number or name as a string (must not be null)public static int getScopeId(java.lang.String scopeName,
java.net.InetAddress compareWith)
scopeName - the scope number or name as a string (must not be null)compareWith - the address to compare with, to ensure that the wrong local scope is not selected (may be null)public static java.net.NetworkInterface findInterfaceWithScopeId(java.lang.String scopeName)
public static int getScopeId(java.net.NetworkInterface networkInterface)
public static int getScopeId(java.net.NetworkInterface networkInterface,
java.net.InetAddress compareWith)
Copyright © 2015 JBoss, a division of Red Hat, Inc.