Java Utililty Methods Byte Array Shorten

List of utility methods to do Byte Array Shorten

Description

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

Method

StringabbrevBytes(long bytes)
abbrev Bytes
if (bytes > 1024 * 1024)
    return String.format("%.1fM", (bytes / (1024.0 * 1024)));
else if (bytes > 1024)
    return bytes / 1024 + "k";
else if (bytes >= 0)
    return "" + bytes;
else
    return "";
...
Stringabbreviate(byte[] bytes, int offset, int maxLength)
Abbreviates to a string to max length
if (bytes == null || offset < 0 || maxLength < 1)
    return EMPTY_STRING;
int msgLength = bytes.length - offset;
int length = msgLength > maxLength ? maxLength : msgLength;
String message = new String(bytes, offset, length);
if (msgLength > maxLength)
    message += ELLIPSIS_STRING;
return message;
...
Stringabbreviate(final byte[] bytes)
abbreviate
return abbreviate(bytes, DEFAULT_ABBREVIATE_MAX_WIDTH);