Human readable DhcpInfo.ipAddress?

后端 未结 5 2155
臣服心动
臣服心动 2021-02-15 10:31

I am wondering how to get a human readable IP Adress from DhcpInfo.ipAddress? The tricky thing about it is, that it is an integer and obviously you can\'t store an IP address in

5条回答
  •  再見小時候
    2021-02-15 11:07

    just reverse the ipaddress which you receive in bytes

    byte[] bytes = BigInteger.valueOf(ipAddress).toByteArray();
    ArrayUtils.reverse(bytes);
    // then
    InetAddress myaddr = InetAddress.getByAddress(ipAddress);
    String ipString = myaddr.getHostAddress();
    

提交回复
热议问题