Convert hexadecimal string to IP Address

后端 未结 6 1561
囚心锁ツ
囚心锁ツ 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:39

    You can split it 2 characters, and then use Integer.parse(string, radix) to convert to integer values

    http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html#parseInt(java.lang.String,int)

    UPDATE: Link for newer documentation: https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#parseInt-java.lang.String-int-

提交回复
热议问题