I’m converting code from perl to java. I’m sort of stuck on finding the equivalents in java.
Here’s my Perl code:
for($i = 0; $i < strlen($hex_); $i = $i + 2)
{
$ascii = $ascii.chr(hexdec(substr($hex_, $i, 2)));
}
so in java i can do hex.substring(i,2). I got that part.
How would I do the chr and hexdec part in Java?
Here’s what I have so far
There is no need for you to go about parsing hexadecimal numbers manually, you can just use Integer.parseInt(String s, int radix). Similarily, there is an Integer.toString(int i, int radix) which will convert your integer to a String with the desired base.