Java Byte Array to Hex bytesToHex(byte[] bytes)

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

Description

Bytes to hex.

License

Open Source License

Parameter

Parameter Description
bytes the bytes to convert to hex.

Return

the hex representation of bytes.

Declaration

private static String bytesToHex(byte[] bytes) 

Method Source Code

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

public class Main {
    /**//from  w  w w.j a v  a 2  s.  co m
     * Bytes to hex.
     *
     * @param bytes the bytes to convert to hex.
     * @return the hex representation of bytes.
     */
    private static String bytesToHex(byte[] bytes) {
        StringBuffer result = new StringBuffer();
        for (byte b : bytes)
            result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
        return result.toString();
    }
}

Related

  1. bytesToHex(byte[] bytes)
  2. bytesToHex(byte[] bytes)
  3. bytesToHex(byte[] bytes)
  4. bytesToHex(byte[] bytes)
  5. bytesToHex(byte[] bytes)
  6. bytesToHex(byte[] bytes, byte[] hex, int offset)
  7. bytesToHex(byte[] bytes, int groupSize)
  8. bytesToHex(byte[] bytes, int size, char delim)
  9. bytesToHex(byte[] data)