"how to autoconvert hexcode to use it as byte[] in java?" Code Answer

4

you could try and put the hex codes into a string and then iterate over the string, similar to this:

string input = "0102ffab";
byte[] bytes = new byte[input.length() / 2];

for( int i = 0; i < input.length(); i+=2)
{
  bytes[i/2] = integer.decode( "0x" + input.substring( i, i + 2 )  ).bytevalue();
}

note that this requires even length strings and it is quite a quick and dirty solution. however, it should still get you started.

By D.S. on February 7 2022

Answers related to “how to autoconvert hexcode to use it as byte[] in java?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.