Android String to Hex String Convert parseHexStr2Byte(String hexStr)

Here you can find the source of parseHexStr2Byte(String hexStr)

Description

parse Hex Str Byte

Declaration

public static byte[] parseHexStr2Byte(String hexStr) 

Method Source Code

//package com.java2s;

public class Main {

    public static byte[] parseHexStr2Byte(String hexStr) {
        if (hexStr.length() < 1)
            return null;
        byte[] result = new byte[hexStr.length() / 2];
        for (int i = 0; i < hexStr.length() / 2; i++) {
            int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1),
                    16);//from   w  w w . ja  v a 2  s.c  om
            int low = Integer.parseInt(
                    hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
            result[i] = (byte) (high * 16 + low);
        }
        return result;
    }
}

Related

  1. toHexString(String str)
  2. hexStr2Str(String hexStr)
  3. hexStringToCommonString(String hexString)
  4. toHex(String txt)
  5. toHex(String txt)
  6. stringToHex(String string)
  7. str2HexStr(String str)
  8. str2HexStrExt(String str)