Java Byte Array to Hex byteToHex(byte[] buffer)

Here you can find the source of byteToHex(byte[] buffer)

Description

byte To Hex

License

Apache License

Declaration

public static String byteToHex(byte[] buffer) 

Method Source Code

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

public class Main {
    public static String byteToHex(byte[] buffer) {
        StringBuffer hexString = new StringBuffer();
        String hex;/*  w w w . j a va2  s  .c om*/
        int iValue;
        for (int i = 0; i < buffer.length; i++) {
            iValue = buffer[i];
            if (iValue < 0)
                iValue += 256;
            hex = Integer.toString(iValue, 16);
            if (hex.length() == 1)
                hexString.append("0" + hex);
            else
                hexString.append(hex);
        }
        return hexString.toString().toUpperCase();
    }
}

Related

  1. byteToHex(byte[] array)
  2. byteToHex(byte[] array, String separator)
  3. byteToHex(byte[] b, int size)
  4. byteToHex(byte[] base)
  5. byteToHex(byte[] buf)
  6. ByteToHex(byte[] bytes)
  7. byteToHex(byte[] content, int nLength)
  8. byteToHex(byte[] raw)
  9. byteToHex(final byte b)