如何将字符串转换为HexaDecimal? [关闭]

问题描述 投票:1回答:1

我有这样的字符串:

"12"

而且我需要将其转换为十六进制值,如下所示:

0x12

我有这样的字节数组

// 00 20 22 80 08 24 pi nn ff ff ff ff ff 
byte VerifyingAPDU[] = { (byte)0x00,(byte)0x20,(byte)0x00,(byte)0x80,(byte)0x08,(byte)0x24,
                     (byte)0x12,(byte)0x34, //pi nn
                     (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff };
Now i want to replace pi nn with user entered value in Eidter (EditText). how to do this ?

例如,用户在编辑器中输入1111,我必须替换Ox12-> 0x11和0x34-> 0x11。

android string hex type-conversion
1个回答
9
投票

应该是

Integer.toHexString(Integer.parseInt(String)); 

Ref:Convert to/from hexadecimal

© www.soinside.com 2019 - 2024. All rights reserved.