Java Byte Array to Hex byteToHex(byte b[])

Here you can find the source of byteToHex(byte b[])

Description

byte To Hex

License

Open Source License

Declaration

public static String byteToHex(byte b[]) 

Method Source Code

//package com.java2s;

public class Main {

    public static String byteToHex(byte b[]) {
        if (b == null) {
            throw new IllegalArgumentException("Argument b ( byte array ) is null! ");
        }/*www .  j a  v a2 s . c  o m*/
        String hs = "";
        String stmp = "";
        for (int n = 0; n < b.length; n++) {
            stmp = Integer.toHexString(b[n] & 0xff);
            if (stmp.length() == 1) {
                hs = hs + "0" + stmp;
            } else {
                hs = hs + stmp;
            }
        }
        return hs.toUpperCase();
    }
}

Related

  1. bytesToHex(StringBuffer buff, byte[] src, int start, int end)
  2. bytesToUnsignedHexes(byte[] bytes)
  3. byteToBcd(byte src)
  4. byteToHex(byte b)
  5. byteToHex(byte b)
  6. byteToHex(byte b[])
  7. byteToHex(byte bytes[])
  8. byteToHex(byte data)
  9. byteToHex(byte[] array)