Java Byte Array to String bytesToStrHex(byte[] bytes)

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

Description

bytes To Str Hex

License

Apache License

Declaration

public static final String bytesToStrHex(byte[] bytes) 

Method Source Code

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

public class Main {

    public static final String bytesToStrHex(byte[] bytes) {
        StringBuffer sb = new StringBuffer(bytes.length);
        String sTemp;//from w w  w  .  j a  v a2  s.co  m
        for (int i = 0; i < bytes.length; i++) {
            sTemp = Integer.toHexString(0xFF & bytes[i]);
            if (sTemp.length() < 2)
                sb.append(0);
            sb.append(sTemp.toUpperCase());
        }
        return sb.toString();
    }
}

Related

  1. bytes2String(byte[] data)
  2. bytes2string(byte[] src)
  3. bytes2string(byte[] src)
  4. bytesToStr(byte[] bytes)
  5. bytesToStr(byte[] input)
  6. bytesToString(byte... bytes)
  7. bytesToString(byte[] arr)
  8. bytesToString(byte[] arr, int pos)
  9. bytesToString(byte[] b)