简体   繁体   中英

Java/Android String to Byte Conversion

I have a String str = "0x01" . I want to convert this string into byte exactly as it is.

I tried doing str.getBytes() and EncodingUtils.getAsciiBytes(str) but it gives byte value of each character I suppose.

I want byte variable to have value as 0x01.

Any idea how do we do it?

Thanks

尝试这个:

byte b = Byte.decode("0x01");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM