Java Byte Array to Hex String bytes_to_hex(byte[] bytes)

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

Description

bytethex

License

Apache License

Declaration

private static String bytes_to_hex(byte[] bytes) 

Method Source Code

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

public class Main {
    final private static char[] hexArray = "0123456789ABCDEF".toCharArray();

    private static String bytes_to_hex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = hexArray[v >>> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }/*from w  w w  .  ja  va  2 s . c  o  m*/
        return new String(hexChars);
    }
}

Related

  1. bytes2hexStr(byte[] arr, int len)
  2. bytes_to_hex(byte[] b)
  3. bytesToHexAppend(byte[] bs, int off, int length, StringBuffer sb)
  4. bytesToHexChars(byte[] bytes)
  5. bytesToHexChars(byte[] bytes)
  6. bytesToHexChars(byte[] bytes)