Java Hex Calculate toHexString(byte[] src)

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

Description

to Hex String

License

Open Source License

Declaration

private static String toHexString(byte[] src) 

Method Source Code

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

public class Main {
    private static String toHexString(byte[] src) {
        StringBuilder stringBuilder = new StringBuilder();
        if (src == null || src.length <= 0) {
            return null;
        }//  w  w  w .  j a  v a  2 s.  com
        for (int i = 0; i < src.length; i++) {
            int v = src[i] & 0xFF;
            String hv = Integer.toHexString(v);
            if (hv.length() < 2) {
                stringBuilder.append(0);
            }
            stringBuilder.append(hv);
        }
        return stringBuilder.toString();
    }
}

Related

  1. toHexString(byte[] messagePayload)
  2. toHexString(byte[] paramArrayOfByte)
  3. toHexString(byte[] paramArrayOfByte, String paramString, boolean paramBoolean)
  4. toHexString(byte[] raw)
  5. toHexString(byte[] raw)
  6. toHexString(byte[] v)
  7. toHexString(byte[] v)
  8. toHexString(byte[] val)
  9. toHexString(byte[] value)