Android Byte Array to String Convert Bcd2Str(byte[] b)

Here you can find the source of Bcd2Str(byte[] b)

Description

Bcd Str

Parameter

Parameter Description
b a parameter

Declaration

public static String Bcd2Str(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* w w w .ja  va 2s  .  c  o m*/
     *
     * @param b
     * @return
     */
    public static String Bcd2Str(byte[] b) {
        StringBuffer sb = new StringBuffer(b.length * 2);

        for (int i = 0; i < b.length; i++) {
            sb.append((byte) (b[i] & 0xF0) >> 4);
            sb.append((byte) (b[i] & 0x0F));
        }

        return sb.toString().substring(0, 1).equalsIgnoreCase("0") ? sb
                .toString().substring(1) : sb.toString();
    }
}

Related

  1. byte2String(byte[] is)
  2. loadConvert(byte[] s, int offset, boolean lengthFlag)
  3. getStringForByte(byte[] bs)
  4. fromBytes(byte abyte0[])
  5. toString(byte[] b, int start, int end)
  6. ByteArrayToString(byte[] input)
  7. byteArrayToString(byte[] b)
  8. byteArrayToString(byte[] bytes)
  9. byteToString(byte b)