List of utility methods to do Byte Array Shorten
String | abbrevBytes(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 ""; ... |
String | abbreviate(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; ... |
String | abbreviate(final byte[] bytes) abbreviate return abbreviate(bytes, DEFAULT_ABBREVIATE_MAX_WIDTH);
|