Android Byte Array to Hex Convert parseByte2HexStr(byte buf[])

Here you can find the source of parseByte2HexStr(byte buf[])

Description

parse Byte Hex Str

Declaration

public static String parseByte2HexStr(byte buf[]) 

Method Source Code

//package com.java2s;

public class Main {

    public static String parseByte2HexStr(byte buf[]) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < buf.length; i++) {
            String hex = Integer.toHexString(buf[i] & 0xFF);
            if (hex.length() == 1) {
                hex = '0' + hex;
            }/*from   w w w  . ja va2  s  .co  m*/
            sb.append(hex.toUpperCase());
        }
        return sb.toString();
    }
}

Related

  1. hexEncode(byte[] data)
  2. encodeHex(byte[] data)
  3. decodeHex(char[] data)
  4. bytesToHex(byte[] data)
  5. bytesToHexString(byte[] bytesArray)
  6. bytesToHex(byte[] bytes)
  7. bytesToHex(byte[] bytes, boolean withSpaces)
  8. byteArrayToHexString(byte[] bytes)
  9. byteArrayToHexString(byte[] bytes)