Java Byte Array to Hex String bytesToHexString(byte abyte0[])

Here you can find the source of bytesToHexString(byte abyte0[])

Description

bytes To Hex String

License

Open Source License

Declaration

public static String bytesToHexString(byte abyte0[]) 

Method Source Code

//package com.java2s;

public class Main {
    public static String bytesToHexString(byte abyte0[]) {
        StringBuilder stringbuilder = new StringBuilder("");
        if (abyte0 == null || abyte0.length <= 0)
            return null;
        for (int i = 0; i < abyte0.length; i++) {
            int j = abyte0[i] & 0xff;
            String s = Integer.toHexString(j);
            if (s.length() < 2)
                stringbuilder.append(0);
            stringbuilder.append(s);//from  ww  w  .j a  v a  2 s.  c  o  m
        }

        return stringbuilder.toString();
    }
}

Related

  1. bytesToHexFormatted(byte[] bytes)
  2. bytesToHexSpaced(byte[] bytes)
  3. bytesToHexStr(byte[] bcd)
  4. bytesToHexStr(byte[] bytes)
  5. bytesToHexStr(byte[] bytes, int offset, int size)
  6. bytesToHexString(byte abyte0[], int i, int j)
  7. bytesToHexString(byte bytes[])
  8. bytesToHexString(byte data[])
  9. bytesToHexString(byte[] _bytes)