java 字符串到十六进制值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1097742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 15:10:47 来源:igfitidea点击:
string to hex value
提问by penguru
Is there any java utility to convert string to hex value (integer) ?
是否有任何 Java 实用程序可以将字符串转换为十六进制值(整数)?
回答by Markus Lausberg
When you have a string starting with 0x or #
当你有一个以 0x 或 # 开头的字符串时
Integer.decode(hexStr);
is the goal
是目标
Or
或者
Integer.parseInt(hexString, 16);
回答by AlbertoPL
Is this what you are looking for?
这是你想要的?
Integer.toHexString(Integer.parseInt(String));
回答by Brian Agnew
Your question is a little ambiguous, I think.
你的问题有点模棱两可,我想。
If you have a hex string (e.g. "ab10"), then you can use
如果您有一个十六进制字符串(例如“ab10”),那么您可以使用
int i = Integer.valueOf(s, 16).intValue();

