Android Hex String to Byte Array Convert toByte(String hexString)

Here you can find the source of toByte(String hexString)

Description

Retrieve the bytes data

License

Open Source License

Parameter

Parameter Description
hexString the source string

Return

the source string's byte data.

Declaration

public static byte[] toByte(String hexString) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from ww w  .j a v  a2 s.  c  om*/
     * Retrieve the bytes data
     * @param hexString the source string
     * @return the source string's byte data.
     */
    public static byte[] toByte(String hexString) {
        int len = hexString.length() / 2;
        byte[] result = new byte[len];
        for (int i = 0; i < len; i++)
            result[i] = Integer.valueOf(
                    hexString.substring(2 * i, 2 * i + 2), 16).byteValue();
        return result;
    }
}

Related

  1. hexStringToBytes(String hex)
  2. hexStringToBytes(String hex)
  3. hexStringToBytes(String hexString)
  4. hexStringToBytes(String hexString)
  5. toByte(String hexString)
  6. hex2byte(String inputString)
  7. fromHex(String hex)
  8. fromHex(String hex)
  9. hexToBytes(String str)