Java Hex Calculate toHexString(byte[] bytes, String separator, boolean upperCase)

Here you can find the source of toHexString(byte[] bytes, String separator, boolean upperCase)

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(byte[] bytes, String separator, boolean upperCase) 

Method Source Code

//package com.java2s;

public class Main {

    public static String toHexString(byte[] bytes, String separator, boolean upperCase) {
        StringBuilder hexString = new StringBuilder();
        for (byte b : bytes) {
            String str = Integer.toHexString(0xFF & b); // SUPPRESS CHECKSTYLE
            if (upperCase) {
                str = str.toUpperCase();
            }/*w  w  w.j  a  va2s  . c o m*/
            if (str.length() == 1) {
                hexString.append("0");
            }
            hexString.append(str).append(separator);
        }
        return hexString.toString();
    }
}

Related

  1. toHexString(byte[] bytes)
  2. toHexString(byte[] bytes)
  3. toHexString(byte[] bytes)
  4. toHexString(byte[] bytes, boolean addPrefix)
  5. toHexString(byte[] bytes, int offset, int len, int max)
  6. toHexString(byte[] coded)
  7. toHexString(byte[] color)
  8. toHexString(byte[] content, int len)
  9. toHexString(byte[] data)