Convert hexadecimal string to IP Address

后端 未结 6 1559
囚心锁ツ
囚心锁ツ 2021-01-02 03:11

I want to convert a string value (in hexadecimal) to an IP Address. How can I do it using Java?

Hex value: 0A064156

IP: 10.6.65.86<

6条回答
  •  隐瞒了意图╮
    2021-01-02 03:34

    try this

    InetAddress a = InetAddress.getByAddress(DatatypeConverter.parseHexBinary("0A064156"));
    

    DatatypeConverter is from standard javax.xml.bind package

提交回复
热议问题