I'm looking for a way to convert a long string (from a dump), which hex in a byte array Represents the value.
I could not say better than the person who posted it on the same question:
But to keep it original, I used to phrase it my own way : Suppose I have a string "00ABF" which I would like to interpret byte [] [0x00,0xA0,0xBf] What should I do?
I am a new Java novice and it has finished using BigTeeger and Head Hex looking for zero but I think it is ugly and I am sure I am missing some simple. ..
Here's a solution I think is better than any post so far:
public static byte [] hexstraat tabetre (strings) {int len = s.length (); Byte [] data = new byte [lane / 2]; (Int i = 0; i & lt; len; i + = 2) {data (I / 2) = (byte) ((character digit (SARATAT (i), 16)
The reason why this correction is:
-
Leading zeros (unlike the BigIntega) and safe with negative byte values (byte contrast Parsbaite)
-
does not convert the string to a
char []
, or creates stringbuilders and string objects for each single byte.
No comments:
Post a Comment