Android String to Hex Byte Array Convert stringToHex(String ids)

Here you can find the source of stringToHex(String ids)

Description

string To Hex

Declaration

public static byte[] stringToHex(String ids) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] stringToHex(String ids) {
        byte[] buf = new byte[ids.length() / 2];

        for (int i = 0, j = 0; i < buf.length; i++, j += 2) {
            byte h = (byte) ((byte) ids.charAt(j) - 0x30);
            byte l = (byte) ((byte) ids.charAt(j + 1) - 0x30);
            buf[i] = (byte) (h << 4 | l);
        }/*from  w ww  .j a  v  a 2s  .co  m*/

        return buf;
    }
}

Related

  1. hexStringToBytes(String hexString)
  2. hexStr2Bytes(String src)
  3. hexStringToBytes(String hex)
  4. getBytes(String hexString)
  5. hexStringToBytes(String hexString)
  6. hexStringToBytes(String s)
  7. hexStringToBytes(String hexString, int offset, int count)
  8. fromHex(String dataString)
  9. fromHexString(String s)