Java Byte Array to Hex String bytesToHexStr(byte[] bcd)

Here you can find the source of bytesToHexStr(byte[] bcd)

Description

bytes To Hex Str

License

Open Source License

Declaration

private static final String bytesToHexStr(byte[] bcd) 

Method Source Code

//package com.java2s;

public class Main {
    private static final char[] bcdLookup = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
            'e', 'f' };

    private static final String bytesToHexStr(byte[] bcd) {
        StringBuffer s = new StringBuffer(bcd.length * 2);

        for (int i = 0; i < bcd.length; i++) {
            s.append(bcdLookup[(bcd[i] >>> 4) & 0x0f]);
            s.append(bcdLookup[bcd[i] & 0x0f]);
        }//from  w  w  w. j a  v a  2s .c  om

        return s.toString();
    }
}

Related

  1. bytesToHexChars(byte[] bytes)
  2. bytesToHexChecksum(byte[] byteArr)
  3. bytesToHexDelimeter(byte[] data, String delimeter)
  4. bytesToHexFormatted(byte[] bytes)
  5. bytesToHexSpaced(byte[] bytes)
  6. bytesToHexStr(byte[] bytes)
  7. bytesToHexStr(byte[] bytes, int offset, int size)
  8. bytesToHexString(byte abyte0[])
  9. bytesToHexString(byte abyte0[], int i, int j)