public final class Address extends Object
Modifier and Type | Method and Description |
---|---|
static int |
addressLength(int family)
Returns the length of an address in a particular family.
|
static int |
familyOf(InetAddress address)
Returns the family of an InetAddress.
|
static InetAddress[] |
getAllByName(String name)
Determines all IP address of a host
|
static InetAddress |
getByAddress(String addr)
Converts an address from its string representation to an IP address.
|
static InetAddress |
getByAddress(String addr,
int family)
Converts an address from its string representation to an IP address in a particular family.
|
static InetAddress |
getByName(String name)
Determines the IP address of a host
|
static String |
getHostName(InetAddress addr)
Determines the hostname for an address
|
static boolean |
isDottedQuad(String s)
Determines if a string contains a valid IP address.
|
static int[] |
toArray(String s)
Convert a string containing an IPv4 address to an array of 4 integers.
|
static int[] |
toArray(String s,
int family)
Convert a string containing an IP address to an array of 4 or 16 integers.
|
static byte[] |
toByteArray(String s,
int family)
Convert a string containing an IP address to an array of 4 or 16 bytes.
|
static String |
toDottedQuad(byte[] addr)
Converts a byte array containing an IPv4 address into a dotted quad string.
|
static String |
toDottedQuad(int[] addr)
Converts an int array containing an IPv4 address into a dotted quad string.
|
static InetAddress |
truncate(InetAddress address,
int maskLength)
Truncates an address to the specified number of bits.
|
public static final int IPv4
public static final int IPv6
public static int[] toArray(String s, int family)
s
- The address, in text format.family
- The address family.public static int[] toArray(String s)
s
- The address, in text format.public static byte[] toByteArray(String s, int family)
s
- The address, in text format.family
- The address family.public static boolean isDottedQuad(String s)
s
- The stringpublic static String toDottedQuad(byte[] addr)
addr
- The arraypublic static String toDottedQuad(int[] addr)
addr
- The arraypublic static InetAddress getByName(String name) throws UnknownHostException
name
- The hostname to look upUnknownHostException
- The hostname does not have any addressespublic static InetAddress[] getAllByName(String name) throws UnknownHostException
name
- The hostname to look upUnknownHostException
- The hostname does not have any addressespublic static InetAddress getByAddress(String addr) throws UnknownHostException
addr
- The address, in string formUnknownHostException
- The address is not a valid IP address.public static InetAddress getByAddress(String addr, int family) throws UnknownHostException
addr
- The address, in string formfamily
- The address family, either IPv4 or IPv6.UnknownHostException
- The address is not a valid IP address in the specified address
family.public static String getHostName(InetAddress addr) throws UnknownHostException
addr
- The address to look upUnknownHostException
- There is no hostname for the addresspublic static int familyOf(InetAddress address)
address
- The supplied address.public static int addressLength(int family)
family
- The address family, either IPv4 or IPv6.public static InetAddress truncate(InetAddress address, int maskLength)
address
- The source addressmaskLength
- The number of bits to truncate the address to.Copyright © 2020 dnsjava.org. All rights reserved.