Java Utililty Methods Byte Array to String

List of utility methods to do Byte Array to String

Description

The list of methods to do Byte Array to String are organized into topic(s).

Method

StringbytesToString(byte[] data)
bytes To String
char[] cs = new char[data.length];
for (int i = 0; i != cs.length; i++) {
    cs[i] = (char) (data[i] & 0xff);
return new String(cs);
StringbytesToString(byte[] data, int start, int end)
Converts a byte array to a hex readable string.
StringBuilder buf = new StringBuilder();
if (end > data.length) {
    end = data.length;
for (int i = start; i < end; i++) {
    buf.append(" ");
    buf.append(Integer.toHexString(data[i] & 0xff));
return buf.toString();
StringbytesToString(byte[] hasher)
This method used for converting byte array to string
String hex = bytesToHexString(hasher);
return hexToString(hex);
StringbytesToString(byte[] id)
Returns a string representation of any part of transaction id.
StringBuffer sb = new StringBuffer(128);
int value;
for (byte b : id) {
    value = b & 0xff;
    sb.append(HEX_DIGITS.charAt(value / 16));
    sb.append(HEX_DIGITS.charAt(value & 15));
return sb.toString();
...
StringbytesToString(byte[] input)
bytes To String
return bytesToString(input, LOWERCASE_DIGITS);
StringbytesToString(byte[] myByte)
Converts array of bytes into string on per-symbol basis, till first 0 value.
return bytesToString(myByte, 0, myByte.length);
StringbytesToString(byte[] value)
bytes To String
StringBuilder buf = new StringBuilder().append("[");
int len = Math.min(value.length, 20);
for (int i = 0; i < len; i++) {
    if (i > 0) {
        buf.append(", ");
    String str = Integer.toHexString(value[i] & 0xFF);
    if (str.length() < 2) {
...
StringbytesToString(char[] bytes, boolean le, boolean signed)
bytes To String
char[] copy = new char[bytes.length];
if (le) {
    for (int i = 0; i < bytes.length / 2; ++i) {
        copy[2 * i] = bytes[bytes.length - 2 * i - 2];
        copy[2 * i + 1] = bytes[bytes.length - 2 * i - 1];
} else {
    System.arraycopy(bytes, 0, copy, 0, copy.length);
...
StringbytesToString(final byte[] arr, final boolean signed, final boolean littleEndian, final String sep)
Returns a string view of a byte array
final StringBuilder sb = new StringBuilder();
final int mask = (signed) ? 0XFFFFFFFF : 0XFF;
final int arrLen = arr.length;
if (littleEndian) {
    for (int i = 0; i < arrLen - 1; i++) {
        sb.append(arr[i] & mask).append(sep);
    sb.append(arr[arrLen - 1] & mask);
...
StringbytesToString(final byte[] bytes)
Returns a string representation of the supplied byte array in hex format.
final StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
    final int v = b & 0xff;
    if (v < 16) {
        sb.append('0');
    sb.append(Integer.toHexString(v)).append(":");
return sb.toString().toUpperCase();