I need to create a summary table at the end of a log with some values that are obtained inside a class. The table needs to be printed in fixed-width format. I have the cod
If you just want a maximum length, use StringUtils.left! No if or ternary ?: needed.
StringUtils.left
if
ternary ?:
int maxLength = 5; StringUtils.left(string, maxLength);
Output:
null -> null "" -> "" "a" -> "a" "abcd1234" -> "abcd1"
Left Documentation