Java Byte to Hex bytes2hex(byte[] binput)

Here you can find the source of bytes2hex(byte[] binput)

Description

byteshex

License

Open Source License

Declaration

public static String bytes2hex(byte[] binput) 

Method Source Code

//package com.java2s;
//    it under the terms of the GNU General Public License as published by

public class Main {
    private static char[] HEXCHARS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
            'F' };

    public static String bytes2hex(byte[] binput) {

        StringBuffer s = new StringBuffer(binput.length * 2);
        for (int i = 0; i < binput.length; i++) {
            byte b = binput[i];
            s.append(HEXCHARS[(b & 0xF0) >> 4]);
            s.append(HEXCHARS[b & 0x0F]);
        }// w w w  .  j a va  2  s.  co m
        return s.toString();
    }
}

Related

  1. bytes2hex(byte[] bts)
  2. bytes2hex(byte[] bytes)
  3. bytes2hex(byte[] bytes)
  4. bytes2hex(byte[] bytes)