Java Byte Array to Hex String bytesToHexString(byte[] _bytes)

Here you can find the source of bytesToHexString(byte[] _bytes)

Description

Wandelt das ggb.

License

Open Source License

Parameter

Parameter Description
_bytes a parameter

Declaration

public static String bytesToHexString(byte[] _bytes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
            'e', 'f' };

    /**//www . j a va2 s. com
     * Wandelt das ggb. ByteArray in einen HexString um
     * 
     * @param _bytes
     * @return
     */
    public static String bytesToHexString(byte[] _bytes) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < _bytes.length; i++) {
            byte b = _bytes[i];
            if ((b < 0) || (b > 0xf)) {
                sb.append(Integer.toHexString(b & 0xFF));
            } else {
                sb.append('0');
                sb.append(hexChars[b]);
            }
        }
        return sb.toString();
    }
}

Related

  1. bytesToHexStr(byte[] bytes, int offset, int size)
  2. bytesToHexString(byte abyte0[])
  3. bytesToHexString(byte abyte0[], int i, int j)
  4. bytesToHexString(byte bytes[])
  5. bytesToHexString(byte data[])
  6. bytesToHexString(byte[] array)
  7. bytesToHexString(byte[] b)
  8. bytesToHexString(byte[] b, int length)
  9. bytesToHexString(byte[] bArray)