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

前端 未结 5 372
南旧
南旧 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:31

    You could try using a regular expression to filter-out non-numeric IP addresses before passing the String to getByName(). Then getByName() will not try name resolution.

提交回复
热议问题