convert hex string to base64
<p>Please help me on converting a hexstring to base64</p>

<p>here is the cede where I'm getting the exception</p>

<pre><code> String hexString = "bf940165bcc3bca12321a5cc4c753220129337b48ad129d880f718d147a2cd1bfa79de92239ef1bc06c2f05886b0cd5d";

private static String ConvertHexStringToBase64(String hexString) {
    System.out.println(hexString);
    if ((hexString.length()) % 2 &gt; 0)
        throw new NumberFormatException("Input string was not in a correct format.");
     byte[] buffer = new byte[hexString.length() / 2];
        int i = 0;
        while (i &lt; hexString.length())
        {
            buffer[i / 2] = Byte.parseByte(hexString.substring(i, 2));
            i += 2;
        }
        System.out.println("hexSring"+hexString+"afterconverttobase64"+Base64.encodeBase64String(buffer));
        return Base64.encodeBase64String(buffer);

}
</code></pre>

<p>I'm getting an exception here::<code>bf940165bcc3bca12321a5cc4c753220129337b48ad129d880f718d147a2cd1bfa79de92239ef1bc06c2f05886b0cd5d
Exception in thread "main" java.lang.NumberFormatException: For input string: "bf"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:449)
    at java.lang.Byte.parseByte(Byte.java:151)
    at java.lang.Byte.parseByte(Byte.java:108)
    at com.motorola.gst.DecryptTest3.ConvertHexStringToBase64(DecryptTest3.java:38)
    at com.motorola.gst.DecryptTest3.main(DecryptTest3.java:16)
</code></p>
