Creating InetAddress object in Java

You should be able to use getByName or getByAddress.

The host name can either be a machine
name, such as “”, or a
textual representation of its IP

InetAddress addr = InetAddress.getByName("");

The method that takes a byte array can be used like this:

byte[] ipAddr = new byte[]{127, 0, 0, 1};
InetAddress addr = InetAddress.getByAddress(ipAddr);

Leave a Comment