Java Byte Array Create toByteArray(String hexString)

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

Description

Get byte array from hex string

License

Apache License

Declaration

public static byte[] toByteArray(String hexString) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from   ww w  .java2  s  . c o m
     * Get byte array from hex string
     */
    public static byte[] toByteArray(String hexString) {
        int arrLength = hexString.length() >> 1;
        byte buff[] = new byte[arrLength];
        for (int i = 0; i < arrLength; i++) {
            int index = i << 1;
            String digit = hexString.substring(index, index + 2);
            buff[i] = (byte) Integer.parseInt(digit, 16);
        }
        return buff;
    }
}

Related

  1. toByteArray(String hex)
  2. toByteArray(String hex)
  3. toByteArray(String hexStr)
  4. toByteArray(String hexString)
  5. toByteArray(String hexString)
  6. toByteArray(String map)
  7. toByteArray(String s)
  8. toByteArray(String source)
  9. toByteArray(String str)