I have an int value which I know is between 0 and 255. I'd like to
obtain a String containing two hex digits from it. I've looked at the
Integer class and while it has a toHexString() method that method can
produce as few as one digit. So if my int was 0 through 15 I'd get
hex '0' thruough 'F'. I could get the length of the string and
"prepend" a second zero in such cases, but I can't help but wonder if
there's a simpler way to do this in Java that I'm missing. Any help
would be greatly appreciated.
Thanks,
Gil
obtain a String containing two hex digits from it. I've looked at the
Integer class and while it has a toHexString() method that method can
produce as few as one digit. So if my int was 0 through 15 I'd get
hex '0' thruough 'F'. I could get the length of the string and
"prepend" a second zero in such cases, but I can't help but wonder if
there's a simpler way to do this in Java that I'm missing. Any help
would be greatly appreciated.
Thanks,
Gil
Comment