public final class NetUtil extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
createByteArrayFromIpAddressString(String ipAddressString)
Creates an byte[] based on an ipAddressString.
|
static Inet6Address |
getByName(CharSequence ip)
Returns the
Inet6Address representation of a CharSequence IP address. |
static Inet6Address |
getByName(CharSequence ip,
boolean ipv4Mapped)
Returns the
Inet6Address representation of a CharSequence IP address. |
static boolean |
isValidIp4Word(String word) |
static boolean |
isValidIpV4Address(String value)
Takes a string and parses it to see if it is a valid IPV4 address.
|
static boolean |
isValidIpV6Address(String ipAddress) |
static String |
toAddressString(InetAddress ip)
Returns the
String representation of an InetAddress . |
static String |
toAddressString(InetAddress ip,
boolean ipv4Mapped)
Returns the
String representation of an InetAddress . |
public static byte[] createByteArrayFromIpAddressString(String ipAddressString)
public static boolean isValidIpV6Address(String ipAddress)
public static boolean isValidIp4Word(String word)
public static boolean isValidIpV4Address(String value)
public static Inet6Address getByName(CharSequence ip)
Inet6Address
representation of a CharSequence
IP address.
This method will treat all IPv4 type addresses as "IPv4 mapped" (see getByName(CharSequence, boolean)
)
ip
- CharSequence
IP address to be converted to a Inet6Address
Inet6Address
representation of the ip
or null
if not a valid IP address.public static Inet6Address getByName(CharSequence ip, boolean ipv4Mapped)
Inet6Address
representation of a CharSequence
IP address.
The ipv4Mapped
parameter specifies how IPv4 addresses should be treated.
"IPv4 mapped" format as
defined in rfc 4291 section 2 is supported.
ip
- CharSequence
IP address to be converted to a Inet6Address
ipv4Mapped
- true
To allow IPv4 mapped inputs to be translated into Inet6Address
false
Don't turn IPv4 addressed to mapped addressesInet6Address
representation of the ip
or null
if not a valid IP address.public static String toAddressString(InetAddress ip)
String
representation of an InetAddress
.
InetAddress.getHostAddress()
The output does not include Scope ID.
ip
- InetAddress
to be converted to an address stringString
containing the text-formatted IP addresspublic static String toAddressString(InetAddress ip, boolean ipv4Mapped)
String
representation of an InetAddress
.
InetAddress.getHostAddress()
ipv4Mapped
is false. If ipv4Mapped
is true then "IPv4 mapped" format
from rfc 4291 section 2 will be supported.
The compressed result will always obey the compression rules defined in
rfc 5952 section 4The output does not include Scope ID.
ip
- InetAddress
to be converted to an address stringipv4Mapped
- true
to stray from strict rfc 5952 and support the "IPv4 mapped" format
defined in rfc 4291 section 2 while still
following the updated guidelines in
rfc 5952 section 4false
to strictly follow rfc 5952String
containing the text-formatted IP addressCopyright © 2008-2015 The Netty Project. All Rights Reserved.