Java Byte Array Create toBytes(String hexString)

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

Description

to Bytes

License

Apache License

Declaration

public static byte[] toBytes(String hexString) 

Method Source Code

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

public class Main {
    public static byte[] toBytes(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();
        }/*  w ww.ja v a  2s .c o  m*/
        return result;
    }
}

Related

  1. toBytes(String hex)
  2. toBytes(String hex)
  3. toBytes(String hex)
  4. toBytes(String hexStr)
  5. toBytes(String hexStr)
  6. toBytes(String hexString)
  7. toBytes(String name)
  8. toBytes(String s)
  9. toBytes(String s, int len, byte pad)