Java Utililty Methods InetAddress Create

List of utility methods to do InetAddress Create

Description

The list of methods to do InetAddress Create are organized into topic(s).

Method

InetAddressgetInetAddress(final int[] octets, final int offset, final int length)

getInetAddress

final byte[] addressBytes = new byte[length];
for (int i = 0; i < addressBytes.length; i++) {
    addressBytes[i] = Integer.valueOf(octets[i + offset]).byteValue();
return getInetAddress(addressBytes);
InetAddressgetInetAddress(final String addressOrName)
get Inet Address
if (isIPAddress(addressOrName)) {
    return getInetAddress(addressOrName);
} else {
    return getInetAddressByName(addressOrName);
InetAddressgetInetAddress(long ip)
get Inet Address
synchronized (ipWorkBytes) {
    byte[] ipBytes = ipWorkBytes;
    long ipAdd = ip;
    ipBytes[0] = (byte) (ipAdd >> 24);
    ipBytes[1] = (byte) (ipAdd >> 16);
    ipBytes[2] = (byte) (ipAdd >> 8);
    ipBytes[3] = (byte) (ipAdd);
    try {
...
StringgetInetAddress(Socket socket)
get Inet Address
String inetAddress = socket == null || socket.getInetAddress() == null ? ""
        : socket.getInetAddress().toString() + ":" + socket.getPort();
if (inetAddress.startsWith("/")) {
    inetAddress = inetAddress.substring(1);
return inetAddress;
InetAddressgetInetAddress(String dottedNotation)
get Inet Address
try {
    return InetAddress.getByName(dottedNotation);
} catch (UnknownHostException e) {
    throw new IllegalArgumentException("Invalid IPAddress " + dottedNotation);
longgetInetAddress(String host)
Computes a long value for the given hostname (or dot notated IP address).
java.net.InetAddress inaddr;
try {
    if (host == null) {
        inaddr = java.net.InetAddress.getLocalHost();
    } else {
        inaddr = java.net.InetAddress.getByName(host);
} catch (java.net.UnknownHostException une) {
...
InetAddressgetInetAddress(String hostName)
Gets the Inet address for the graylog2ServerHost and gives a specialised error message if an exception is thrown
try {
    return InetAddress.getByName(hostName);
} catch (UnknownHostException e) {
    throw new IllegalStateException("Unknown host: " + e.getMessage()
            + ". Make sure you have specified the 'graylog2ServerHost' property correctly in your logback.xml'");
InetAddressgetInetAddress(String name)
Get an InetAddress by name returning null if there is an error resolving the name.
try {
    return InetAddress.getByName(name);
} catch (Exception ex) {
    return null;
InetAddressgetInetAddress(String str)
get Inet Address
byte addr[];
addr = getNumericAddress4(str);
if (addr == null)
    addr = getNumericAddress6(str);
if (addr == null)
    return null;
try {
    return InetAddress.getByAddress(new String(), addr);
...
InetAddressgetInetAddressByName(String name)
get Inet Address By Name
try {
    return InetAddress.getByName(name);
} catch (Exception ex) {
    throw new RuntimeException(ex);