Java Hex Calculate toHexString(byte b)

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

Description

to Hex String

License

Apache License

Declaration

public static String toHexString(byte b) 

Method Source Code

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

public class Main {
    public static String toHexString(byte b) {
        String s = Integer.toHexString(b & 0xFF).toUpperCase();
        return (s.length() == 2) ? (s) : ("0" + s);
    }//from   www  . j av a 2  s  . c o m

    public static String toHexString(byte[] b) {
        return toHexString(b, " ");
    }

    public static String toHexString(byte[] b, String glue) {
        String s = "";
        if (null != b && null != glue) {
            for (int i = 0; i < b.length; i++) {
                s += (i == 0 ? "" : glue) + toHexString(b[i]);
            }
        }
        return s;
    }
}

Related

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