Java Byte Array to String byteToStr(byte[] byteArray)

Here you can find the source of byteToStr(byte[] byteArray)

Description

byte To Str

License

Open Source License

Declaration

private static String byteToStr(byte[] byteArray) 

Method Source Code

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

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

    private static String byteToStr(byte[] byteArray) {
        String strDigest = "";
        for (int i = 0; i < byteArray.length; i++) {
            strDigest += byteToHexStr(byteArray[i]);
        }/*from  w w w.ja v a  2  s  .co m*/
        return strDigest;
    }

    private static String byteToHexStr(byte mByte) {
        char[] tempArr = new char[2];
        tempArr[0] = digit[(mByte >>> 4) & 0X0F];
        tempArr[1] = digit[mByte & 0X0F];
        String s = new String(tempArr);
        return s;
    }
}

Related

  1. bytesToString(long bytes)
  2. bytesToString(long size)
  3. byteTo16String(byte[] bt)
  4. byteToMacString(byte[] data)
  5. byteToStr(byte[] byteArray)
  6. ByteToString(byte[] a, int nLen)
  7. byteToString(byte[] array, int byteLength)
  8. byteToString(byte[] b)
  9. byteToString(byte[] bByte)