Java Byte Array to String bytes2string(byte[] src)

Here you can find the source of bytes2string(byte[] src)

Description

bytesstring

License

Open Source License

Declaration

public static String bytes2string(byte[] src) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String bytes2string(byte[] src) {
        StringBuilder sb = new StringBuilder();
        if (src == null || src.length <= 0) {
            return null;
        }//  www.j  a v a  2 s .  co m
        for (int i = 0; i < src.length; i++) {
            int v = src[i] & 0xFF;
            String hv = Integer.toHexString(v);
            if (hv.length() < 2) {
                sb.append(0);
            }
            sb.append(hv.toUpperCase());
        }
        return sb.toString();
    }
}

Related

  1. bytes2String(byte[] bytes)
  2. bytes2String(byte[] bytes)
  3. bytes2String(byte[] bytes)
  4. bytes2String(byte[] bytesArray)
  5. bytes2String(byte[] data)
  6. bytes2string(byte[] src)
  7. bytesToStr(byte[] bytes)
  8. bytesToStr(byte[] input)
  9. bytesToStrHex(byte[] bytes)