Java Hex Calculate toHex(final byte[] bytes)

Here you can find the source of toHex(final byte[] bytes)

Description

to Hex

License

Open Source License

Declaration

public static String toHex(final byte[] bytes) 

Method Source Code

//package com.java2s;

public class Main {
    public final static char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
            'f' };

    public static String toHex(final byte[] bytes) {
        final char[] buffer = new char[bytes.length * 2];
        for (int i = 0; i < bytes.length; i++) {
            buffer[i * 2] = hex[(bytes[i] & 0xf0) >> 4];
            buffer[i * 2 + 1] = hex[bytes[i] & 0xf];
        }//from w w  w  . ja va  2s.c  o m
        return new String(buffer);
    }
}

Related

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