Java Binary to Hex BinaryToHexString(byte[] bytes)

Here you can find the source of BinaryToHexString(byte[] bytes)

Description

Binary To Hex String

License

Apache License

Declaration

public static String BinaryToHexString(byte[] bytes) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static String hexStr = "0123456789ABCDEF";

    public static String BinaryToHexString(byte[] bytes) {
        String result = "";
        String hex = "";
        for (int i = 0; i < bytes.length; i++) {
            hex = String.valueOf(hexStr.charAt((bytes[i] & 0xF0) >> 4));
            hex += String.valueOf(hexStr.charAt(bytes[i] & 0x0F));
            result += hex;//from  w ww  .  j  av  a 2  s. co m
        }
        return result;
    }
}

Related

  1. binaryToHex(byte[] ba)
  2. binaryToHex(byte[] bytes)
  3. binaryToHex(byte[] data)
  4. binaryToHex(char[] binaryStr)
  5. binaryToHex(int binary)
  6. binaryToHexString(String binaryValue)
  7. binToHex(byte[] bin)
  8. binToHex(byte[] bytes)
  9. binToHex(byte[] data)