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

Stringbytes2Str(byte[] bytes, String separator)
Converts byte array to string
StringBuilder stringBuilder = new StringBuilder();
for (int index = 0; index < bytes.length; index++) {
    stringBuilder.append(index == 0 ? "" : separator).append(((int) bytes[index]) & 0xFF);
return stringBuilder.toString();
Stringbytes2String(byte[] args)
bytes String
String str = new String(args);
return str;
Stringbytes2String(byte[] b, int start, int len)
bytes String
return new String(b, start, len);
Stringbytes2String(byte[] bs, String charset)
bytes String
if (null == bs) {
    return EMPTY_STRING;
String s = null;
try {
    s = new String(bs, charset);
} catch (Exception e) {
return s;
Stringbytes2String(byte[] buffer, int offset, int length)
bytes String
StringBuilder sb = new StringBuilder();
for (int i = offset; i < offset + length; i++) {
    byte b = buffer[i];
    sb.append(String.format("%02X", b));
    sb.append(" ");
return sb.toString();
Stringbytes2String(byte[] bytes)
bytes String
if (bytes == null || bytes.length == 0)
    return "";
StringBuffer sb = new StringBuffer();
for (byte b : bytes)
    sb.append(byte2HEX(b));
return sb.toString();
Stringbytes2String(byte[] bytes)
bytes String
StringBuilder string = new StringBuilder();
for (byte b : bytes) {
    String hexString = Integer.toHexString(0x00FF & b);
    string.append(hexString.length() == 1 ? "0" + hexString : hexString);
return string.toString();
Stringbytes2String(byte[] bytes)
bytes String
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
    stringBuffer.append((char) bytes[i]);
return stringBuffer.toString();
Stringbytes2String(byte[] bytesArray)
bytes String
String result = "";
for (Byte bts : bytesArray) {
    result += (char) bts.intValue();
return result;
Stringbytes2String(byte[] data)
bytes String
if (data == null)
    return null;
if (data.length == 0)
    return "";
StringBuilder sb = new StringBuilder();
for (byte b : data) {
    sb.append(b).append(' ');
return sb.toString();