I am doing a assignment about this.
For Eaxmple: I have a message (String), and the length is 302 in dec, 12e in hex.
String message = "THE MESSAGE BODY";
int lengthOfMessage = number.length(); // 302
String lengthOfMessageInHex = Integer.toHexString(lengthOfMessage); // 12e
Now, I need to change the lengthOfMessageInHex from "12e" to "0000012e".
lengthOfMessageInHex = ("00000000" + lengthOfMessageInHex)
.substring(lengthOfMessageInHex.length()); // 0000012e
And Now I would like to store 00 00 01 2e to a new byte[4].
How can I do it??
Thank You.