Is there an easy way to convert String to Inetaddress in Java?

前端 未结 5 370
南旧
南旧 2020-12-20 10:46

I am trying to convert strings into Inetaddress. I am not trying to resolve hostnames: the strings are ipv4 addresses. Does InetAddress.getByName(String h

5条回答
  •  鱼传尺愫
    2020-12-20 11:39

    Yes, that will work. The API is very clear on this ("The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address."), and of course you could easily check yourself.

提交回复
热议问题