Java Hex Calculate toHex(byte b, String prefix)

Here you can find the source of toHex(byte b, String prefix)

Description

to Hex

License

Open Source License

Declaration

public static String toHex(byte b, String prefix) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

public class Main {
    public static final String HEX_PREFIX = "0x";

    public static String toHex(byte b) {
        return toHex(b, HEX_PREFIX);
    }// w  w w.j  a  va 2s .co  m

    public static String toHex(byte b, String prefix) {
        return prefix + String.format("%02x", b);
    }

    public static String toHex(short s) {
        return toHex(s, HEX_PREFIX);
    }

    public static String toHex(short s, String prefix) {
        return prefix + String.format("%04x", s);
    }
}

Related

  1. toHex(byte b)
  2. toHex(byte b)
  3. toHex(byte b)
  4. toHex(byte b)
  5. toHex(byte b, char[] charArray, int from)
  6. toHex(byte bytes[])
  7. toHex(byte data[])
  8. toHex(byte hash[])
  9. toHex(byte in)