Java Hex Calculate toHexString(byte[] value)

Here you can find the source of toHexString(byte[] value)

Description

to Hex String

License

LGPL

Declaration

public static String toHexString(byte[] value) 

Method Source Code

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

public class Main {

    public static String toHexString(byte[] value) {
        String newString = "";
        for (int i = 0; i < value.length; i++) {
            byte b = value[i];
            String str = Integer.toHexString(b);
            if (str.length() > 2) {
                str = str.substring(str.length() - 2);
            }//from w  w w .  j av a 2s  .  c  o  m
            if (str.length() < 2) {
                str = "0" + str;
            }
            newString += str;
        }
        return newString.toUpperCase();
    }
}

Related

  1. toHexString(byte[] raw)
  2. toHexString(byte[] src)
  3. toHexString(byte[] v)
  4. toHexString(byte[] v)
  5. toHexString(byte[] val)
  6. toHexString(byte[] value)
  7. toHexString(byte[] value, int startOffset, int maxLength, boolean uppercase, char separator)
  8. toHexString(char c)
  9. toHexString(final byte b)