Android String to Byte Array Convert String2Byte(String hexString)

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

Description

String Byte

Declaration

public static byte[] String2Byte(String hexString) 

Method Source Code

//package com.java2s;

public class Main {

    public static byte[] String2Byte(String hexString) {
        if (hexString.length() % 2 == 1)
            return null;
        byte[] ret = new byte[hexString.length() / 2];
        for (int i = 0; i < hexString.length(); i += 2) {
            ret[i / 2] = Integer.decode(
                    "0x" + hexString.substring(i, i + 2)).byteValue();
        }//from   ww  w. ja  v a2s  .  c o  m
        return ret;
    }
}

Related

  1. getBytes(String s)
  2. getBytes(String data)
  3. getBytes(String data, String charsetName)
  4. getBytesFromAddress(String address)
  5. stringToBytes(String string)
  6. StringToByteArray(String input)
  7. StrToBcdBytes(String s)
  8. Str2Bcd(String asc)
  9. toBytes(String digits, int radix)