Java Byte to Hex byteToHex(byte b)

Here you can find the source of byteToHex(byte b)

Description

Converts the given byte to a hex String.

License

Open Source License

Declaration

public static String byteToHex(byte b) 

Method Source Code

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

public class Main {
    /**/*from  ww  w.ja  va 2  s  .  c  o  m*/
     * Converts the given byte to a hex String.
     */
    public static String byteToHex(byte b) {
        String hex = Integer.toHexString(b);
        if (hex.length() >= 2) {
            return hex.substring(hex.length() - 2);
        }

        return String.format("0%s", hex);
    }
}

Related

  1. bytesToUpperCaseHex(byte[] b)
  2. byteToHex(byte a)
  3. byteToHex(byte b)
  4. byteToHex(byte b)
  5. byteToHex(byte b)
  6. byteToHex(byte b)
  7. byteToHex(byte b)
  8. byteToHex(byte b)
  9. byteToHex(byte b)