I am trying to convert strings into Inetaddress
. I am not trying to resolve hostnames: the strings are ipv4 addresses. Does InetAddress.getByName(String host)
work? Or do I have to manually parse it?
in_addr_t inet_addr(const char *strptr) This function call converts the specified string in the Internet standard dot notation to an integer value suitable for use as an Internet address.
An IP address is represented by 32-bit or 128-bit unsigned number. InetAddress can handle both IPv4 and IPv6 addresses.
com.google.common.net.InetAddresses.forString(String ipString)
is better for this as it will not do a DNS lookup regardless of what string is passed to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With