Android Byte Array to Hex Convert toHexStringArray(byte[] data, int offset, int length)

Here you can find the source of toHexStringArray(byte[] data, int offset, int length)

Description

to Hex String Array

Declaration

public static String[] toHexStringArray(byte[] data, int offset,
            int length) 

Method Source Code

//package com.java2s;

public class Main {
    static final char[] HEXS = new char[] { '0', '1', '2', '3', '4', '5',
            '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

    public static String[] toHexStringArray(byte[] data, int offset,
            int length) {
        String[] result = new String[length];
        StringBuilder s = new StringBuilder(length * 2);
        int end = offset + length;

        int high_nibble;
        int low_nibble;

        for (int i = offset, j = 0, k = 0; i < end; i++, j++, k += 2) {
            high_nibble = (data[i] & 0xF0) >>> 4;
            low_nibble = (data[i] & 0x0F);

            s.append(HEXS[high_nibble]);
            s.append(HEXS[low_nibble]);/* w w w  . j  av  a  2 s  .  c om*/

            result[j] = s.substring(k);
        }

        s.delete(0, s.length() - 1);
        s = null;

        return result;
    }
}

Related

  1. toHexString(byte[] bytes)
  2. toHexString(byte[] bytes, int numBytes)
  3. toHexString(byte[] bytes, int offset, int length)
  4. toHexString(byte[] data)
  5. toHexString(byte[] data, int offset, int length)
  6. convertToHexString(byte[] input)
  7. dumpHex(byte[] bytes)
  8. getBinaryStrFromByteArr(byte[] bArr)
  9. toHex(byte[] buf)