Search code examples
javaiphexconverters

Convert hexadecimal string to IP Address


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

This site gives me the correct result, but I am not sure how to implement this in my code.

Can it be done directly in an XSLT?


Solution

  • try this

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

    DatatypeConverter is from standard javax.xml.bind package