I have a string like
01 01 01 02 01 01 20 00 40 0b 00 01 ef cc 45 4e 47 00 1a 02
How can I read this as input? I know declaring
String s = "01 01 01 02 01 01 20 00 40 0b 00 01 ef cc 45 4e 47 00 1a 02"
will obviously throw me error, so what are different possible ways I can read this input (passed as arguments) using Java?
I’m assuming you want to read this in as hexadecimal data, not as a string.
Start by removing the whitespace in the string, so it should look like “0101010201012000400b0001efcc454e47001a02”
Then, create a BigInteger to hold it like so:
Now you should have the hexadecimal value stored in the variable hex.