Android Hex String Create toHexByte(String str, int offset, int length)

Here you can find the source of toHexByte(String str, int offset, int length)

Description

to Hex Byte

Declaration

public static byte[] toHexByte(String str, int offset, int length) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] toHexByte(String str, int offset, int length) {
        byte[] data = new byte[(length - offset) * 2];

        int end = offset + length;

        int high_nibble;
        int low_nibble;

        for (int i = offset; i < end; i++) {
            char ch = str.charAt(i);
            high_nibble = (ch & 0xF0) >>> 4;
            low_nibble = ch & 0x0F;/*ww  w  .  ja v  a2  s.  co  m*/

            data[i] = (byte) high_nibble;
            data[i + 1] = (byte) low_nibble;
        }
        return data;
    }
}

Related

  1. toHex(byte b)
  2. toHex(byte input[])
  3. toHex(byte[] bytes)
  4. toHex(byte[] data)
  5. toHex(int address)
  6. toHexChar(int i)
  7. toHexDigits(byte theByte)
  8. toHexDigits(byte[] bytes)
  9. toHexString(byte oneByte)