Unable to parse as integer Android
<p>i'm using a function to decrypt data recieved as JSON format when i tested the function it give me the error unable to parse 'str' as integer</p>

<p>the function :</p>

<pre><code>public static byte[] hexToBytes(String str) {
        if (str==null) {
                return null;
        } else if (str.length() &lt; 2) {
                return null;
        } else {
                int len = str.length() / 2;
                byte[] buffer = new byte[len];
                for (int i=0; i&lt;len; i++) {
                        buffer[i] = (byte) Integer.parseInt(str.substring(i*2,i*2+2),16);
                }
                return buffer;
        }
}
</code></pre>

<p>thanks in advance</p>
