string to hex value

前端 未结 4 2006
粉色の甜心
粉色の甜心 2021-01-05 18:53

Is there any java utility to convert string to hex value (integer) ?

相关标签:
4条回答
  • 2021-01-05 19:07

    Is this what you are looking for?

    Integer.toHexString(Integer.parseInt(String));
    
    0 讨论(0)
  • 2021-01-05 19:23

    When you have a string starting with 0x or #

    Integer.decode(hexStr);
    

    is the goal

    Or

    Integer.parseInt(hexString, 16);
    
    0 讨论(0)
  • 2021-01-05 19:30

    Your question is a little ambiguous, I think.

    If you have a hex string (e.g. "ab10"), then you can use

    int i = Integer.valueOf(s, 16).intValue();
    
    0 讨论(0)
  • 2021-01-05 19:32

    Try some of the methods of the Integer class:

    Integer.toHexString(Integer.parseInt(myString, 10))
    

    This assumes that your original string is an integer base ten.

    0 讨论(0)
提交回复
热议问题