Java Hex Calculate toHexString(byte[] data)

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

Description

to Hex String

License

Apache License

Declaration

private static String toHexString(byte[] data) 

Method Source Code

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

public class Main {
    private static final char[] hexCode = "0123456789abcdef".toCharArray();

    private static String toHexString(byte[] data) {
        if (data == null) {
            return null;
        }/*w w w  .j  a  va  2 s. c  om*/
        StringBuilder r = new StringBuilder(data.length * 2);
        for (byte b : data) {
            r.append(hexCode[(b >> 4) & 0xF]);
            r.append(hexCode[(b & 0xF)]);
        }
        return r.toString();
    }
}

Related

  1. toHexString(byte[] data)
  2. toHexString(byte[] data)
  3. toHexString(byte[] data)
  4. toHexString(byte[] data)
  5. toHexString(byte[] data)
  6. toHexString(byte[] data)
  7. toHexString(byte[] data)
  8. toHexString(byte[] data)
  9. toHexString(byte[] data, final int offset, final int count)