Android Utililty Methods Byte Array to String Convert

List of utility methods to do Byte Array to String Convert

Description

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

Method

Stringbase16(byte[] data)
base
return byteArray2HexString(data);
ListByteArrayToStringList(byte[] byteArray, int dataLength)
Converts a byte array into a String array
if (byteArray == null) {
    return null;
if (dataLength <= 0) {
    return null;
if (dataLength > byteArray.length) {
    return null;
...
StringtoStringForm(byte[] arr)
to String Form
StringBuilder sb = new StringBuilder();
for (byte b : arr) {
    sb.append(((int) b) + "");
return sb.toString();
StringtoStringUntil(byte[] b, int pos, byte until)
to String Until
StringBuilder str = new StringBuilder();
while (true) {
    if (b.length <= pos) {
        return null;
    byte ch = b[pos];
    if (ch == until) {
        break;
...
StringtoStringWithLength(byte[] b, int pos, int length)
to String With Length
StringBuilder str = new StringBuilder();
for (int i = 0; i < length; i++) {
    str.append((char) b[pos + i]);
String ret = str.toString();
return ret;
voidprintBytes(byte[] bytes, StringBuilder builder, int bytesPerLine)
print Bytes
for (int i = 0; i < bytes.length; i++) {
    if (i != 0 && i % bytesPerLine == 0) {
        builder.append("\n");
    builder.append(String.format("%02x  ", bytes[i]));
StringprintBytes(byte[] bytes, int bytesPerLine)
print Bytes
StringBuilder builder = new StringBuilder();
printBytes(bytes, builder, bytesPerLine);
return builder.toString();
voidprintBytes(byte[] data, String type)
print Bytes
if (type == null) {
    type = "";
System.out.println();
System.out.println(bytes2StringPtr(data, type));
System.out.println();
ByteStringbytesToByteString(byte[] bytes)
bytes To Byte String
return ByteString.copyFrom(bytes);
StringtoText(byte[] arr)
To text?
String ret = "";
if (arr != null && arr.length > 0) {
    for (int i = 0; i < arr.length; i++) {
        if (i > 0) {
            ret += ".";
        int b = toUnsignedInteger(arr[i]);
        ret += b;
...