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

Stringarr2String(byte[] arr, int start)
arr String
int offset = 0;
while (arr[start + offset] != 0) {
    offset++;
return new String(arr, start, offset);
StringASCIIByteArrayToString(byte[] data)
Convert a byte array into a 2 byte per character Java String by adding a 0-byte in front of each byte.
StringBuilder r = new StringBuilder("");
for (byte b : data) {
    r.append((char) (b & 0xFF));
return r.toString();
StringasString(byte[] a, String separator)
Converts a array of numbers into a String.
StringBuffer sbuff = new StringBuffer();
for (int i = 0; i < a.length; i++)
    sbuff.append(a[i] + separator);
sbuff.setLength(sbuff.length() - 1);
return sbuff.toString();
StringasString(byte[] array)
Converts the given byte array to a string using a default separator character.
return asString(array, ':');
StringasString(byte[] bs)
As string.
StringBuilder buf = new StringBuilder();
for (byte b : bs) {
    if (buf.length() != 0) {
        buf.append(':');
    if (b >= 0 && b < 16) {
        buf.append('0');
    buf.append(Integer.toHexString((b < 0) ? b + 256 : b).toUpperCase());
return buf.toString();
StringasString(byte[] buf)
as String
StringBuffer strbuf = new StringBuffer(buf.length);
for (int i = 0; i < buf.length; i++) {
    strbuf.append((char) buf[i]);
return strbuf.toString();
StringasString(byte[] bytes)
Return the String representation of the byte array.
if (bytes == null) {
    return null;
if (bytes.length == 0) {
    return EMPTY_STRING;
return new String(bytes);
StringasString(byte[] bytes)
as String
if (bytes != null) {
    return new String(bytes);
} else {
    return "";
StringByteArrayToString(byte[] byteArray)
Byte Array To String
return Arrays.toString(byteArray);
Stringbytes2str(byte[] arr)
Converts a byte array to a String .
return new String(arr);